From aa6d7498a2fc7edda677141ac907290337c311c2 Mon Sep 17 00:00:00 2001 From: Chad Birch Date: Fri, 5 Oct 2018 21:44:50 -0600 Subject: [PATCH] Handle timezone in get_delta_from_subject() --- ago.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ago.py b/ago.py index b3d9760..8816d18 100644 --- a/ago.py +++ b/ago.py @@ -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):