moksha/lib/helpers.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
New commits: commit 69e9107b41c483b7d636d2dd1f3f59af76d153bb Author: Luke Macken lmacken@redhat.com Date: Wed May 13 10:14:29 2009 -0400
More DateTimeDisplay tweaks
diff --git a/moksha/lib/helpers.py b/moksha/lib/helpers.py index 5177e02..70954a4 100644 --- a/moksha/lib/helpers.py +++ b/moksha/lib/helpers.py @@ -934,8 +934,8 @@ class DateTimeDisplay(object): '1 day' >>> d.age(datetime(2010, 7, 10, 10, 10), granularity='minute') '1 year, 1 month, 29 days, 10 hours and 10 minutes' - >>> d.age(tz='US/Eastern') - '1 day and 11 hours' + >>> d.age(datetime(2010, 7, 10, 10, 10), tz='Europe/Amsterdam') + '1 year, 1 month, 29 days and 10 hours' >>> d = DateTimeDisplay(datetime(2009, 5, 12, 12, 0, 0)) >>> d.timestamp datetime.datetime(2009, 5, 12, 12, 0) @@ -968,13 +968,12 @@ class DateTimeDisplay(object): """ start = self.datetime if not end: - if tz: - tz = timezone(tz) - end = datetime.now(utc) - end = end.astimezone(tz) - start = self.datetime.replace(tzinfo=utc) - start = tz.normalize(start.astimezone(tz)) - else: - end = datetime.utcnow() + end = datetime.utcnow() + if tz: + zone = timezone(tz) + #end = zone.localize(end) + end = end.replace(tzinfo=utc) + end = zone.normalize(end.astimezone(zone)) + start = self.astimezone(tz)
return distance_of_time_in_words(start, end, granularity=granularity)
moksha-commits@lists.fedorahosted.org