Kushal Kumaran <[email protected]> writes:
> Yes, but the documentation for utcnow explicitly tells you how to get
> an aware object.
>
> "An aware current UTC datetime can be obtained by calling
> datetime.now(timezone.utc)."
And in Python 2.7 you can just copy the definition of utc from the doc and use
that:
from datetime import tzinfo, timedelta, datetime
ZERO = timedelta(0)
class UTC(tzinfo):
"""UTC"""
def utcoffset(self, dt):
return ZERO
def tzname(self, dt):
return "UTC"
def dst(self, dt):
return ZERO
utc = UTC()
--
Piet van Oostrum <[email protected]>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
--
https://mail.python.org/mailman/listinfo/python-list