mirror of
https://github.com/internetarchive/warcprox.git
synced 2025-01-18 13:22:09 +01:00
make UTC a constant available externally
This commit is contained in:
parent
073c1fb578
commit
1c07ae2ea9
@ -8,16 +8,17 @@ import socket
|
|||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
try:
|
||||||
|
UTC = datetime.timezone.utc
|
||||||
|
except:
|
||||||
|
UTC = r.make_timezone("00:00")
|
||||||
|
|
||||||
def utcnow():
|
def utcnow():
|
||||||
"""Convenience function to get timezone-aware UTC datetime. RethinkDB
|
"""Convenience function to get timezone-aware UTC datetime. RethinkDB
|
||||||
requires timezone-aware datetime for its native time type, and
|
requires timezone-aware datetime for its native time type, and
|
||||||
unfortunately datetime.datetime.utcnow() is not timezone-aware. Also python
|
unfortunately datetime.datetime.utcnow() is not timezone-aware. Also python
|
||||||
2 doesn't come with a timezone implementation."""
|
2 doesn't come with a timezone implementation."""
|
||||||
try:
|
return datetime.datetime.now(UTC)
|
||||||
utc = datetime.timezone.utc
|
|
||||||
except:
|
|
||||||
utc = r.make_timezone("00:00")
|
|
||||||
return datetime.datetime.now(utc)
|
|
||||||
|
|
||||||
class RethinkerWrapper(object):
|
class RethinkerWrapper(object):
|
||||||
logger = logging.getLogger('rethinkstuff.RethinkerWrapper')
|
logger = logging.getLogger('rethinkstuff.RethinkerWrapper')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user