Introduces International Atomic Time (TAI) milliseconds, and methods for converting these to and from conventional Unix milliseconds. Unix time tracks

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-12-26 10:30:04

Introduces International Atomic Time (TAI) milliseconds, and methods for converting these to and from conventional Unix milliseconds.

Unix time tracks the number of elapsed UTC milliseconds since 1970-01-01 00:00:00 UTC, excluding leap seconds. (Unix time can equally well be measured in seconds, but here we use milliseconds because this is how a JavaScript Date object works.)

Because Unix time ignores leap seconds, it is not generally possible to determine the true amount of elapsed time between any two Unix timestamps by simply subtracting one from the other. Equally, it is not safe to add a time interval to a Unix timestamp and expect to receive a new Unix timestamp which is separated from the first Unix timestamp by that interval. Results will be wrong by the number of leap seconds in the interval, which depends on when the interval started and ended.

TAI milliseconds track the number of elapsed TAI milliseconds since 1970-01-01 00:00:00 TAI. TAI does not have leap seconds. Using TAI, all of the above problems are easily solved as follows:

Leave a Comment