Leap Seconds
A leap second is a second UTC inserts at the end of a day and the clock reads as 23:59:60. The
mistakes around it are three: treating the spelling as proof the second exists, treating TAI − UTC as
a whole number for every date, and treating the difference of two UTC readings as the seconds that
passed. Every output shown here is what the function returns.
Leap seconds and TAI
Section titled “Leap seconds and TAI”Using hasSecond60 as a leap-second check
hasSecond60 tests the spelling of the seconds field, which Temporal would silently clamp to 59. A second 60 is well-formed on any day and real on 27 of them. isLeapSecond looks the day up in the leap-second table.
Wrong
import { hasSecond60 } from "@northguild/gmt/plain/validate";
hasSecond60("2017-12-31T23:59:60Z");// true — well-formed, and no second was inserted that dayRight
import { isLeapSecond } from "@northguild/gmt/timescale/validate";
isLeapSecond("2017-12-31T23:59:60Z");// falseisLeapSecond("2016-12-31T23:59:60Z");// trueThe Leap Second Timeline checks the end of 2017 against the listed insertions.
Using a whole number for TAI − UTC before 1972
UTC differed from TAI by whole seconds only from 1972-01-01. Before that the difference was fractional and changed daily, so a constant of 10 seconds is not a lower bound. taiMinusUtc returns null for an earlier date, and toTAI returns an empty string.
Wrong
const taiMinusUtc = () => 10; // the first whole-second value, for every datetaiMinusUtc("1971-12-31T23:59:59Z");// 10 — in 1971 the difference was not a whole numberRight
import { taiMinusUtc } from "@northguild/gmt/timescale/calculate";import { toTAI } from "@northguild/gmt/timescale/convert";
taiMinusUtc("1971-12-31T23:59:59Z");// nulltaiMinusUtc("1972-01-01T00:00:00Z");// 10toTAI("1971-12-31T00:00:00Z");// ""The Leap Second Timeline shows what it gives for the last second of 1971.
Reading a span across an insertion as the seconds that passed
UTC repeats a second rather than numbering a 61st, so the difference of two UTC readings across an insertion is one second short of the time that passed. leapSecondsBetween counts the insertions in the span, signed, and the true elapsed time is the clock difference plus that count.
Wrong
import { spanNs } from "@northguild/gmt/span/calculate";
spanNs("2016-12-31T23:00:00Z", "2017-01-01T01:00:00Z");// 7200000000000n — two hours of clock, one second short of two hours elapsedRight
import { spanNs } from "@northguild/gmt/span/calculate";import { leapSecondsBetween } from "@northguild/gmt/timescale/calculate";
spanNs("2016-12-31T23:00:00Z", "2017-01-01T01:00:00Z");// 7200000000000nleapSecondsBetween("2016-12-31T23:00:00Z", "2017-01-01T01:00:00Z");// 1Elapsed vs. Clock Difference shows the same two readings with the clock difference and the elapsed seconds side by side.
© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.