Mercurial > p > roundup > code
diff roundup/anypy/datetime_.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 | |
| children | 6894f152d49a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/roundup/anypy/datetime_.py Tue Jul 25 16:30:10 2023 -0400 @@ -0,0 +1,12 @@ +# https://issues.roundup-tracker.org/issue2551278 +# datetime.utcnow deprecated +try: + from datetime import now, UTC + + def utcnow(): + return now(UTC) +except ImportError: + import datetime + + def utcnow(): + return datetime.datetime.utcnow()
