Unix time and leap seconds

Campa picture Campa · May 14, 2013 · Viewed 18k times · Source

Regarding Unix (POSIX) time, Wikipedia says:

Due to its handling of leap seconds, it is neither a linear representation of time nor a true representation of UTC.

But the Unix date command does not seem to be aware of them actually

$ date -d '@867715199' --utc
Mon Jun 30 23:59:59 UTC 1997
$ date -d '@867715200' --utc
Tue Jul  1 00:00:00 UTC 1997

While there should be a leap second there at Mon Jun 30 23:59:60 UTC 1997.

Does this mean that only the date command ignores leap seconds, while the concept of Unix time doesn't?

Answer

Thomas Jung picture Thomas Jung · May 14, 2013

The number of seconds per day are fixed with Unix timestamps.

The Unix time number is zero at the Unix epoch, and increases by exactly 86400 per day since the epoch.

So it cannot represent leap seconds. The OS will slow down the clock to accommodate for this. The leap seconds is simply not existent as far a Unix timestamps are concerned.