Hacker News new | past | comments | ask | show | jobs | submit login

NTP provides UTC. UTC deviates from TAI by a number of whole seconds, the original offset plus all the leap seconds added since.



So you subtract the number of leap seconds from the UTC clock to get TAI? How do you update the number of leap seconds to subtract?


You never do this sort of conversion manually.

On linux you can use clock_gettime() with CLOCK_TAI:

       CLOCK_TAI (since Linux 3.10; Linux-specific)
              A nonsettable system-wide clock derived from wall-clock time
              but ignoring leap seconds.  This clock does not experience
              discontinuities and backwards jumps caused by NTP inserting
              leap seconds as CLOCK_REALTIME does.

              The acronym TAI refers to International Atomic Time.

Now, leap seconds are advertised in advance and your system know when they occur through a leap seconds file (leap-seconds.list) that needs to be kept up to date.


Ah, thanks. I didn't think it sounded like something to do in application code.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: