Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit cf687d7

Browse files
authored
Merge pull request #45 from IdentityPython/fix-timestamp-tz
Fix calculation of epoch that is not taking into account the timezone
2 parents 1e2ee16 + 407e90e commit cf687d7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/oidcmsg/time_util.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ def later_than(after, before):
348348

349349

350350
def utc_time_sans_frac():
351-
return int((datetime.utcnow() - datetime(1970, 1, 1)).total_seconds())
351+
now_timestampt = int(datetime.utcnow().timestamp())
352+
return now_timestampt
352353

353354

354355
def time_sans_frac():
@@ -372,4 +373,5 @@ def epoch_in_a_while(
372373
"""
373374

374375
dt = time_in_a_while(days, seconds, microseconds, milliseconds, minutes, hours, weeks)
375-
return int((dt - datetime(1970, 1, 1)).total_seconds())
376+
dt_timestamp = int(dt.timestamp())
377+
return dt_timestamp

0 commit comments

Comments
 (0)