comparison roundup/date.py @ 7587:8f29e4ea05ce

fix: issue2551278 - datetime.datetime.utcnow deprecation. Replace calls with equivalent that produces timezone aware dates rather than naive dates. Also some flake8 fixes for test/rest_common.py.
author John Rouillard <rouilj@ieee.org>
date Tue, 25 Jul 2023 16:30:10 -0400
parents c27276e0bdce
children 2bf0c4e7795e
comparison
equal deleted inserted replaced
7586:859c57bc8d91 7587:8f29e4ea05ce
21 __docformat__ = 'restructuredtext' 21 __docformat__ = 'restructuredtext'
22 22
23 import calendar 23 import calendar
24 import datetime 24 import datetime
25 import re 25 import re
26
27 from roundup.anypy.datetime_ import utcnow
26 28
27 try: 29 try:
28 import pytz 30 import pytz
29 except ImportError: 31 except ImportError:
30 pytz = None 32 pytz = None
374 raise ValueError('Unknown spec %r' % (spec,)) 376 raise ValueError('Unknown spec %r' % (spec,))
375 377
376 def now(self): 378 def now(self):
377 """ To be able to override for testing 379 """ To be able to override for testing
378 """ 380 """
379 return datetime.datetime.utcnow() 381 return utcnow()
380 382
381 def set(self, spec, offset=0, date_re=date_re, 383 def set(self, spec, offset=0, date_re=date_re,
382 serialised_re=serialised_date_re, add_granularity=False): 384 serialised_re=serialised_date_re, add_granularity=False):
383 ''' set the date to the value in spec 385 ''' set the date to the value in spec
384 ''' 386 '''

Roundup Issue Tracker: http://roundup-tracker.org/