Author vstinner
Recipients belopolsky, doughellmann, vstinner
Date 2015-03-03.15:45:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1425397519.12.0.495744554121.issue23574@psf.upfronthosting.co.za>
In-reply-to
Content
support_leap_seconds.patch: different approach, accept second=60. Problem: fromtimestamp() returns the wrong day.

haypo@smithers$ ./python
Python 3.5.0a1+ (default:760f222103c7+, Mar  3 2015, 15:36:36) 
>>> import datetime
>>> datetime.datetime(2012, 6, 30, 23, 59, 60)
datetime.datetime(2012, 6, 30, 23, 59, 60)
>>> dt1=datetime.datetime(2012, 6, 30, 23, 59, 60)
>>> t1=datetime.datetime(2012, 6, 30, 23, 59, 60).timestamp()
>>> dt2=datetime.datetime.fromtimestamp(t1)
>>> dt2
datetime.datetime(2012, 7, 1, 0, 0)
>>> dt2 == dt1
False
>>> dt1
datetime.datetime(2012, 6, 30, 23, 59, 60)
>>> print(dt1)
2012-06-30 23:59:60
>>> print(dt2)
2012-07-01 00:00:00

>>> import time
>>> time.mktime((2012, 6, 30, 23, 59, 60, -1, -1, -1))
1341093600.0
>>> t1
1341093600.0
>>> t2=time.mktime((2012, 6, 30, 23, 59, 60, -1, -1, -1))
>>> t2 == t1
True
>>> time.localtime(time.mktime((2012, 6, 30, 23, 59, 60, -1, -1, -1)))
time.struct_time(tm_year=2012, tm_mon=7, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=183, tm_isdst=1)


http://cr.yp.to/proto/utctai.html

"""
For many years, the UNIX localtime() time-display routine didn't support leap seconds.
(...)
Why not fix it?
(...)
The main obstacle is POSIX. POSIX is a ``standard'' designed by a vendor consortium several years ago to eliminate progress and protect the installed base. The behavior of the broken localtime() libraries was documented and turned into a POSIX requirement.
"""
History
Date User Action Args
2015-03-03 15:45:19vstinnersetrecipients: + vstinner, belopolsky, doughellmann
2015-03-03 15:45:19vstinnersetmessageid: <1425397519.12.0.495744554121.issue23574@psf.upfronthosting.co.za>
2015-03-03 15:45:19vstinnerlinkissue23574 messages
2015-03-03 15:45:18vstinnercreate