8

I want to know if there is a name for a function/method/library that converts a given date object with time information into something like:

a few seconds ago
2 minutes ago
about an hour ago
10 hours ago
yesterday
on 12-May-2010

and so on. I don't know what to google for, but I'm guessing that someone must have done this before. I'm specifically looking for an implementation in python (preferably a Django filter) that works on a datetime, but any open source implementation in any language will do really, for inspiration.

Motti
  • 110,860
  • 49
  • 189
  • 262
Klaus Byskov Pedersen
  • 117,245
  • 29
  • 183
  • 222
  • 3
    No idea what it's called but you can find a language-agnostic answer I gave to an earlier question here: http://stackoverflow.com/questions/1570752/how-do-you-say-something-happened-x-minutes-ago-or-x-hours-ago-or-x-days-ago/1570843#1570843 – paxdiablo Nov 12 '10 at 09:31

3 Answers3

6

Google for "Fuzzy Date Time"

Dirk Brockhaus
  • 4,922
  • 3
  • 38
  • 47
2

I believe it is called "fuzzy timestamp" (also "timedelta")

A ref followed by the suffix @ with a date specification enclosed in a brace pair (e.g. {yesterday}, {1 month 2 weeks 3 days 1 hour 1 second ago} or {1979-02-26 18:30:00}) to specify the value of the ref at a prior point in time.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I don't really know the name of the method used, but you can find a Javascript implementation of what you're describing at DateJS.

Valentin Rocher
  • 11,667
  • 45
  • 59