On Sun, Aug 2, 2015 at 9:46 AM, Guido van Rossum email@example.com wrote:
There's a simpler reason for ignoring leap seconds in datetime: Python's wall clock is mappable to POSIX timestamps, which also ignore leap seconds (the reason being Tim's long explanation :-).
Note that if you combine several recently made proposals, you can have a fully backward-compatible solution for leap seconds. You can simply use time(23, 59, ss, us, first=False) to stand for times in the 23:60 minute and delegate arithmetics to the tzinfo object:
def __add__(self, delta): try: add = self.tzinfo.add except AttributeError: # current logic else: return add(self, delta)
Same for `__sub__` and possibly `strftime`, `isoformat`, etc. if you want time(23, 59, ss, us, first=False) to be printed as 23:60:ss.us.
Note that Olson database contains information about leap seconds, so once you have access to that and a way to spell 23:60 (as the repeated 23:59!) you can easily implement "correct" UTC timezone.
On the other hand, I would like to proceed in baby steps. Let's first implement the means to disambiguate repeated times and various improvements that it will allow to the existing datetime functionality. Meanwhile the developers of timezone libraries will hopefully embrace the new feature and improve their offerings.
Hopefully, by the time we are ready to distribute a full TZ database with Python, the problem of distribution will be solved by IETF . If their solution (as expected) includes leap second information, we can find a way to give Python users access to it in one way or another.