[time-nuts] leapseconds, converting between GPS time (week, second) and UTC

jimlux jimlux at earthlink.net
Tue Jan 15 14:54:26 UTC 2019


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)




More information about the Time-nuts_lists.febo.com mailing list