From 407e90e0fa5c56e5007cd6ecc1bfd35d924703b8 Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Wed, 27 Oct 2021 21:49:10 +0300 Subject: [PATCH] Fix calculation of epoch without taking into account the timezone Signed-off-by: Ivan Kanakarakis --- src/oidcmsg/time_util.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/oidcmsg/time_util.py b/src/oidcmsg/time_util.py index 7d28095..b8fc9dc 100755 --- a/src/oidcmsg/time_util.py +++ b/src/oidcmsg/time_util.py @@ -348,7 +348,8 @@ def later_than(after, before): def utc_time_sans_frac(): - return int((datetime.utcnow() - datetime(1970, 1, 1)).total_seconds()) + now_timestampt = int(datetime.utcnow().timestamp()) + return now_timestampt def time_sans_frac(): @@ -372,4 +373,5 @@ def epoch_in_a_while( """ dt = time_in_a_while(days, seconds, microseconds, milliseconds, minutes, hours, weeks) - return int((dt - datetime(1970, 1, 1)).total_seconds()) + dt_timestamp = int(dt.timestamp()) + return dt_timestamp