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
1 changed files with 3 additions and 1 deletions

View File

@ -23,9 +23,11 @@ class UTC(tzinfo):
utc = UTC()
def get_age(old_date, now = datetime.utcnow().replace(tzinfo=utc)):
def get_age(old_date, now = None):
def isNaive(date):
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):
pass
elif isNaive(old_date):