[Python-ideas] Happy leap second

Guido van Rossum guido at python.org
Sat Jun 30 18:29:58 CEST 2012

On Sat, Jun 30, 2012 at 8:18 AM, Alexander Belopolsky
<alexander.belopolsky at gmail.com> wrote:
> On Sat, Jun 30, 2012 at 10:57 AM, Guido van Rossum <guido at python.org> wrote:
>> POSIX timestamps don't have leap seconds. Convince POSIX to change
>> that and Python will follow suit.
> POSIX (time_t) timestamps are mostly irrelevant for the users of the
> datetime module.  POSIX type that is closest to datetime.datetime is
> struct tm and it does have leap seconds:
> """
> The <time.h> header shall declare the structure tm, which shall
> include at least the following members:
> int    tm_sec   Seconds [0,60].
> ...
> """  - http://pubs.opengroup.org/onlinepubs/009696699/basedefs/time.h.html
> Note that that POSIX does require that a round-trip through time_t
> (localtime(mktime(x))) converts hh:59:60 to (hh+1):00:00, but
> datetime.timestamp() can still do the same if we make second=60 valid.

The roundtrip requirement is telling though -- they have no way to
actually represent a leap second in the underlying clock (which is a
POSIX timestamp).

--Guido van Rossum (python.org/~guido)

More information about the Python-ideas mailing list