Package django :: Package utils :: Module timesince
[hide private]
[frames] | no frames]

Module timesince

source code

Functions [hide private]
 
timesince(d, now=None)
Takes two datetime objects and returns the time between d and now as a nicely formatted string, e.g.
source code
 
timeuntil(d, now=None)
Like timesince, but returns a string measuring the time until the given time.
source code

Imports: datetime, time, tzinfo.LocalTimezone, translation.ungettext, translation.ugettext


Function Details [hide private]

timesince(d, now=None)

source code 

Takes two datetime objects and returns the time between d and now as a nicely formatted string, e.g. "10 minutes". If d occurs after now, then "0 minutes" is returned.

Units used are years, months, weeks, days, hours, and minutes. Seconds and microseconds are ignored. Up to two adjacent units will be displayed. For example, "2 weeks, 3 days" and "1 year, 3 months" are possible outputs, but "2 weeks, 3 hours" and "1 year, 5 days" are not.

Adapted from http://blog.natbat.co.uk/archive/2003/Jun/14/time_since