This library doesn't seem to produce valid UTCTime values.
amano-kenji opened this issue · 2 comments
getCurrentTime :: IO UTCTime
uses systemToUTCTime
which doesn't account for leap seconds.
getSystemTime
doesn't seem to account for leap seconds.
getPOSIXTime
doesn't account for leap seconds. posixSecondsToUTCTime
doesn't account for leap seconds.
It seems to me that no chain of functions can produce a valid UTCTime.
The documentation says
UTC is time as measured by a clock, corrected to keep pace with the earth by adding or removing occasional seconds, known as "leap seconds". These corrections are not predictable and are announced with six month's notice. No table of these corrections is provided, as any program compiled with it would become out of date in six months.
UTC needs to account for leap seconds. Where are leap seconds accounted for? Is any haskell program using time
library incapable of displaying local time or UTC time after accounting for leap seconds?
On a correctly-configured system, getCurrentTime
will give the correct UTC time, except during a leap-second. Is that the problem?
I researched leap second, and it turns out that ntp either slows down the system clock or steps the system clock back by one second after leap second. Thus, leap second is already accounted for in the system clock.
So, software developers don't have to think about leap seconds as long as leap second is taken care of by ntpd.