datetimegnuunix-timestampleap-second

How does Unix Epoch time behave on a leap smeared clock?


Consider a machine whose time is smeared during a leap second with a noon-to-noon linear smear.

I'm wondering how the system clock provides accurate Epoch time during the smear period.

Example:

How is this inaccuracy resolved? Does the local Epoch time skip a second once the system knows a leap second happened? Or how is this issue handled?
Does it depend on the implementation of the clock used to calculate the time? If so, how does GNU's coreutils date handle this?


Solution

  • The inaccuracy is not resolved. The Unix Time remains a count of seconds since 1970-01-01 00:00:00 UTC excluding the inserted leap seconds. This has the benefit of making the count of seconds easy to convert to {year, month, day, hour, minute, second} form.

    It has the problem that the subtraction of two Unix Time time points that straddle a leap second insertion will result in a time duration that is one second less than reality.