Skip to content

Leap Seconds

  • The core functions, which every industry uses.

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.

HIGH

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 day

Right

import { isLeapSecond } from "@northguild/gmt/timescale/validate";
isLeapSecond("2017-12-31T23:59:60Z");
// false
isLeapSecond("2016-12-31T23:59:60Z");
// true
output 

The Leap Second Timeline checks the end of 2017 against the listed insertions.

MEDIUM

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 date
taiMinusUtc("1971-12-31T23:59:59Z");
// 10 — in 1971 the difference was not a whole number

Right

import { taiMinusUtc } from "@northguild/gmt/timescale/calculate";
import { toTAI } from "@northguild/gmt/timescale/convert";
taiMinusUtc("1971-12-31T23:59:59Z");
// null
taiMinusUtc("1972-01-01T00:00:00Z");
// 10
toTAI("1971-12-31T00:00:00Z");
// ""
output 

The Leap Second Timeline shows what it gives for the last second of 1971.

HIGH

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 elapsed

Right

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");
// 7200000000000n
leapSecondsBetween("2016-12-31T23:00:00Z", "2017-01-01T01:00:00Z");
// 1
output 

Elapsed vs. Clock Difference shows the same two readings with the clock difference and the elapsed seconds side by side.

Accessibility
© 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.