From aaeb2e2e55581bad35417dcc4dafa9f65290ae95 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Jul 2012 23:49:30 +0530 Subject: [PATCH] fix in pretty date's timedelta calc --- py/webnotes/utils/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/py/webnotes/utils/__init__.py b/py/webnotes/utils/__init__.py index d28b281d88..eccc8da8fb 100644 --- a/py/webnotes/utils/__init__.py +++ b/py/webnotes/utils/__init__.py @@ -731,7 +731,12 @@ def pretty_date(iso_datetime): iso_datetime = datetime.strptime(iso_datetime, '%Y-%m-%d %H:%M:%S') now_dt = datetime.strptime(now(), '%Y-%m-%d %H:%M:%S') dt_diff = now_dt - iso_datetime - dt_diff_seconds = dt_diff.total_seconds() + + # available only in python 2.7+ + # dt_diff_seconds = dt_diff.total_seconds() + + dt_diff_seconds = dt_diff.days * 86400.0 + dt_diff.seconds + dt_diff_days = math.floor(dt_diff_seconds / 86400.0) # differnt cases