Kushal Kumaran <kushal.kuma...@gmail.com> writes: > Ben Finney <ben+pyt...@benfinney.id.au> writes: > > > Kushal Kumaran <kushal.kuma...@gmail.com> writes: > > > >> Roy Smith <r...@panix.com> writes: > >> > How, in Python, do you get an aware UTC datetime object? > >> > >> classmethod datetime.utcnow() > >> > >> Return the current UTC date and time, with tzinfo None. […] > > > > No, that won't do what was asked. The ‘datetime.datetime.utcnow’ > > function explicitly returns a naive datetime object, not an aware > > datetime object. > > 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 we come full circle: This is exactly what Roy's original question was (IIUC) trying to address. That process is not obvious, and it's not simple: it's a series of difficult-to-discover function calls instead of just one obvious one. -- \ “If you don't know what your program is supposed to do, you'd | `\ better not start writing it.” —Edsger W. Dijkstra | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list