A Leap Second That Never Happened
A Leap Second That Never Happened
A feed delivers 2017-12-31T23:59:60Z. A validation rule accepts any timestamp with a seconds field of 60 as a real leap second. Is it one?
The naive approach
// The naive approach: a seconds field of 60 means a leap second
import { hasSecond60 } from "@northguild/gmt/plain/validate";
hasSecond60("2017-12-31T23:59:60Z");
// true — well-formed, so the rule accepts itWatch it break
The naive approach silently produces wrong results — there is no GMT equivalent to demonstrate because the failure is not using GMT.
Why
A seconds field of 60 is well-formed on any day, and Temporal silently clamps it to 59, so a syntax test has a job: it catches the spelling. It cannot say whether the second exists. UTC has had 27 inserted seconds, the last on 2016-12-31, and the table of them is closed. `isLeapSecond` looks the day up, in any offset spelling, and answers false for every other second 60.
The gmt approach
import { isLeapSecond } from "@northguild/gmt/timescale/validate";
isLeapSecond("2017-12-31T23:59:60Z");
// false — no second was inserted that day
isLeapSecond("2016-12-31T23:59:60Z");
// true
isLeapSecond("2017-01-01T08:59:60+09:00");
// true — the same inserted second, written in another offsetSame widget, working
In the widget, change the year to 2016 and the answer turns true. Change it to any other year and it stays false. The Leap Second Timeline draws every listed insertion and checks the end of 2017 against them, and the rules are in Leap Seconds and TAI.
© 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.