fixed prettydate, thanks Anthony
This commit is contained in:
1 parent
06cba402cb
commit
f78f27982b
2 files changed
+7
-3
No files matched your search
@@ -1 +1 @@
|
||||
Version 2.00.0 (2012-08-16 10:54:35) dev
|
||||
Version 2.00.0 (2012-08-16 11:06:01) dev
|
||||
+6
-2
@@ -4251,10 +4251,14 @@ def completion(callback):
|
||||
return _completion
|
||||
|
||||
def prettydate(d,T=lambda x:x):
|
||||
try:
|
||||
if isinstance(d,datetime.datetime):
|
||||
dt = datetime.datetime.now() - d
|
||||
except:
|
||||
elif isinstance(d,datetime.date):
|
||||
dt = datetime.date.today() - d
|
||||
elif not d:
|
||||
return ''
|
||||
else:
|
||||
return '[invalid date]'
|
||||
if dt.days >= 2*365:
|
||||
return T('%d years ago') % int(dt.days / 365)
|
||||
elif dt.days >= 365:
|
||||
|
||||
Reference in new issue
Block a user