Permalink
Browse files

support web.datestr for datetime.date objects also

  • Loading branch information...
1 parent 4db7f39 commit 23248e3adf7f3ad4fbd21be03f141659f2f38003 @aaronsw aaronsw committed with anandology Jan 27, 2009
Showing with 3 additions and 0 deletions.
  1. +3 −0 web/utils.py
View
@@ -565,6 +565,9 @@ def agohence(n, what, divisor=None):
now = datetime.datetime.fromtimestamp(now)
if type(then).__name__ == "DateTime":
then = datetime.datetime.fromtimestamp(then)
+ elif type(then).__name__ == "date":
+ then = datetime.datetime(then.year, then.month, then.day)
+
delta = now - then
deltaseconds = int(delta.days * oneday + delta.seconds + delta.microseconds * 1e-06)
deltadays = abs(deltaseconds) // oneday

0 comments on commit 23248e3

Please sign in to comment.