AFIK no programming systems professing POSIX compliance implements Leap Seconds. There is however a timezone UTCLeapSeconds will allow this apparently.
>> t1.TimeZone = ‘UTCLeapSeconds' Obviously youR TZ data base needs to have it and your Python needs to be at the required level; My test didn’t work, maybe I am not at the right levels. >>> t1 = datetime >>> t1.timezone = 'UTCLeapSeconds' >>> t1 = datetime.datetime(2016,12,31,23,59,58) >>> dt = datetime.timedelta(seconds=1) >>> print t1 2016-12-31 23:59:58 >>> print t1+dt 2016-12-31 23:59:59 >>> print t1+dt+dt 2017-01-01 00:00:00 >>> print t1+dt+dt+dt 2017-01-01 00:00:01 I guess the same facility exists for other programming systems MATLAB has it I believe. Google is your friend. Mike > Le 15 janv. 2019 à 15:54, jimlux <[email protected]> a écrit : > > I'm working with a variety of things which work in UTC or GPS > week/millisecond, so we're doing a lot of conversion back and forth. > (the spacecraft puts out time in week:millisecond, all the ground systems > processing is in UTC) > > The question comes up when converting back and forth, and whether various > libraries handle leap seconds correctly. > For now, I can use a hack of not computing back to 6 Jan 1980, but use an > epoch like 15 Dec 2018 (week 2031: 518,400.000 seconds) and hope there's no > leap second in the offing. > > > For instance, in Python, if I do a datetime(2016,12,31,0,0,0) + > timedelta(hours=30) does it come out as 1/1/2017 6:00:00 or 5:59:59 (it > comes out 0600) > > Similarly, does Excel's time formatting allow for some minutes having an > extra second, or does it just assume all minutes are 60 seconds. > > I'll probably test it for the cases I'm interested in (Ruby, Python, Excel, > Matlab, Octave), but if someone else has already done it, then I've got > something to cross check against. > > > (python does NOT know about leap seconds) > > import datetime > > d = datetime.datetime(2016,12,31) > > dt = datetime.timedelta(hours=30) > > d > Out[4]: datetime.datetime(2016, 12, 31, 0, 0) > > dt > Out[5]: datetime.timedelta(1, 21600) > > d+dt > Out[6]: datetime.datetime(2017, 1, 1, 6, 0) > > _______________________________________________ > time-nuts mailing list -- [email protected] > To unsubscribe, go to > http://lists.febo.com/mailman/listinfo/time-nuts_lists.febo.com > and follow the instructions there. I am not a a vegetarian because I love animals. I’m a vegetarian because I hate plants. _______________________________________________ time-nuts mailing list -- [email protected] To unsubscribe, go to http://lists.febo.com/mailman/listinfo/time-nuts_lists.febo.com and follow the instructions there.
