From 6bf884da669055051259e34a1fa70b5d23f5de96 Mon Sep 17 00:00:00 2001 From: Tanshu Date: Fri, 7 Jun 2013 14:57:56 +0530 Subject: [PATCH] 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 --- brewman/brewman/models/tzinfoutc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/brewman/brewman/models/tzinfoutc.py b/brewman/brewman/models/tzinfoutc.py index 07b5530a..b9445a67 100644 --- a/brewman/brewman/models/tzinfoutc.py +++ b/brewman/brewman/models/tzinfoutc.py @@ -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):