What does python return on the leap second

Leap seconds are occasionally manually scheduled. Currently, computer clocks have no facility to honour leap seconds; there is no standard to tell them up-front to insert one. Instead, computer clocks periodically re-synch their time keeping via the NTP protocol and adjust automatically after the leap second has been inserted.

Next, computer clocks usually report the time as seconds since the epoch. It'd be up to the datetime module to adjust its accounting when converting that second count to include leap seconds. It doesn't do this at present. time.time() will just report a time count based on the seconds-since-the-epoch.

So, nothing different will happen when the leap second is officially in effect, other than that your computer clock will be 1 second of for a little while.

The issues with datetime only cover representing a leap second timestamp, which it can't. It won't be asked to do so anyway.


Python's mktime behavior here is pretty much just inherited from C's, which is specified by POSIX. The spec isn't as simple as you might think, and the reality is even more complicated.

I think this article is a good introduction to the various issues: The Unix leap second mess

The datetime module, as you observed, just acts like there is no such thing as a leap second.