the Gravity of Python 2

Chris Angelico rosuav at gmail.com
Wed Jan 8 20:47:53 EST 2014


On Thu, Jan 9, 2014 at 12:27 PM, Roy Smith <roy at panix.com> wrote:
> Anyway, I discovered that Python 3.3's datetime has a .timestamp()
> method.  Yeah.  Finally.  Exactly what the world had needed for years.
> Then I kept reading and found:
>
> Note: There is no method to obtain the POSIX timestamp directly from a
> naive datetime instance representing UTC time.

In my experiments (admittedly with 3.4, not 3.3, but I don't know that
there's any difference), I was able to round-trip a time_t through
datetime with no problems. Why not simply use a UTC datetime instead
of a naive one? What do you gain by using a naive datetime? You seem
to know what timezone it's in anyway.

ChrisA



More information about the Python-list mailing list