]> granicus.if.org Git - python/commit
Issue #25155: Add _PyTime_AsTimevalTime_t() function
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 18 Sep 2015 11:23:02 +0000 (13:23 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 18 Sep 2015 11:23:02 +0000 (13:23 +0200)
commit1e2b6882fc28a3cded227f55e4dc3f937afd678e
tree761eed5c9da66d8748b6382cd49589850cdf1e49
parent1bd0b54c74ea7a108e4a7d921bf9ff904c6fa4d7
Issue #25155: Add _PyTime_AsTimevalTime_t() function

On Windows, the tv_sec field of the timeval structure has the type C long,
whereas it has the type C time_t on all other platforms. A C long has a size of
32 bits (signed inter, 1 bit for the sign, 31 bits for the value) which is not
enough to store an Epoch timestamp after the year 2038.

Add the _PyTime_AsTimevalTime_t() function written for datetime.datetime.now():
convert a _PyTime_t timestamp to a (secs, us) tuple where secs type is time_t.
It allows to support dates after the year 2038 on Windows.

Enhance also _PyTime_AsTimeval_impl() to detect overflow on the number of
seconds when rounding the number of microseconds.
Include/pytime.h
Modules/_datetimemodule.c
Python/pytime.c