1515# See the License for the specific language governing permissions and
1616# limitations under the License.
1717"""
18- Implements some usefull functions when dealing with validity of
18+ Implements some useful functions when dealing with validity of
1919different types of information.
2020"""
2121
2222import calendar
23+ from datetime import datetime
24+ from datetime import timedelta
25+ from datetime import timezone
2326import logging
2427import re
25- import sys
2628import time
27- from datetime import datetime
28- from datetime import timedelta
2929
3030TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
3131TIME_FORMAT_WITH_FRAGMENT = re .compile ("^(\d{4,4}-\d{2,2}-\d{2,2}T\d{2,2}:\d{2,2}:\d{2,2})\.\d*Z$" )
@@ -181,7 +181,8 @@ def time_in_a_while(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0
181181 :return: datetime instance using UTC time
182182 """
183183 delta = timedelta (days , seconds , microseconds , milliseconds , minutes , hours , weeks )
184- return datetime .utcnow () + delta
184+ res = datetime .now (timezone .utc ) + delta
185+ return res .replace (tzinfo = None )
185186
186187
187188def time_a_while_ago (
@@ -200,7 +201,8 @@ def time_a_while_ago(
200201 :return: datetime instance using UTC time
201202 """
202203 delta = timedelta (days , seconds , microseconds , milliseconds , minutes , hours , weeks )
203- return datetime .utcnow () - delta
204+ res = datetime .now (timezone .utc ) - delta
205+ return res .replace (tzinfo = None )
204206
205207
206208def in_a_while (
@@ -350,8 +352,8 @@ def later_than(after, before):
350352 return after >= before
351353
352354
353- def utc_time_sans_frac ():
354- now_timestampt = int (datetime .utcnow ( ).timestamp ())
355+ def utc_time_sans_frac (): # MUST be the same as utc_time_sans_frac in cryptojwt
356+ now_timestampt = int (datetime .now ( timezone . utc ).timestamp ())
355357 return now_timestampt
356358
357359
0 commit comments