Hopefully now the probem displaying thread age should be fixed.

Default arguments of python funtions are evaluated only on definition time.

Signed-off-by: Tanshu <tanshu@gmail.com>
This commit is contained in:
Tanshu 2013-06-07 14:57:56 +05:30
parent d111c7b41c
commit 6bf884da66

View File

@ -23,9 +23,11 @@ class UTC(tzinfo):
utc = UTC() utc = UTC()
def get_age(old_date, now = datetime.utcnow().replace(tzinfo=utc)): def get_age(old_date, now = None):
def isNaive(date): def isNaive(date):
return date.tzinfo is None or date.tzinfo.utcoffset(date) is None return date.tzinfo is None or date.tzinfo.utcoffset(date) is None
if now is None:
now = datetime.utcnow().replace(tzinfo=utc)
if isNaive(old_date) == isNaive(now): if isNaive(old_date) == isNaive(now):
pass pass
elif isNaive(old_date): elif isNaive(old_date):