Handle timezone in get_delta_from_subject()

This commit is contained in:
Chad Birch 2018-10-05 21:44:50 -06:00
parent 217a7fbe61
commit aa6d7498a2

7
ago.py
View file

@ -20,11 +20,8 @@ def get_delta_from_subject(subject):
dt = datetime.fromtimestamp(subject)
# strip timezone data
dt = dt.replace(tzinfo=None)
# finally, return a timedelta from the datetime
return datetime.now() - dt
# return a timedelta from the datetime, using its timezone (if it has one)
return datetime.now(tz=dt.tzinfo) - dt
def delta2dict(delta):