Re: [Datetime-SIG] Calendar vs timespan calculations...
On Sunday, August 2, 2015, Alexander Belopolsky < alexander.belopolsky@gmail.com <javascript:_e(%7B%7D,'cvml','alexander.belopolsky@gmail.com');>> wrote:
On Sun, Aug 2, 2015 at 9:46 AM, Guido van Rossum <guido@python.org> 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.
I don't have much time to respond now, but please don't add leap seconds. People are actively working to get rid of them entirely and they are never useful on the business level which this module is aimed at.
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 [1]. 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.
[1]: https://tools.ietf.org/html/draft-ietf-tzdist-service-11 _______________________________________________ Datetime-SIG mailing list Datetime-SIG@python.org https://mail.python.org/mailman/listinfo/datetime-sig The PSF Code of Conduct applies to this mailing list: https://www.python.org/psf/codeofconduct/
-- Łukasz Rekucki
participants (1)
-
Łukasz Rekucki