Handle timezone in get_delta_from_subject()
This commit is contained in:
parent
217a7fbe61
commit
aa6d7498a2
1 changed files with 2 additions and 5 deletions
7
ago.py
7
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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue