Skip to content

isLeapSecond

isLeapSecond(value: string): boolean

Return true if the provided ISO 8601 date-time or time string has a second-60 field.

  • This is a syntactic test of the seconds field, the spelling Temporal would silently clamp to :59. It does not check the IERS leap-second list: a real leap second exists only at 23:59:60 UTC at the end of a month in which one was inserted (RFC 3339 §5.7), so "2024-12-31T23:59:60Z" (no leap second that day, IERS Bulletin C 68) and "2024-06-15T12:34:60Z" both return true.
  • Matches a seconds field of 60 with any date, time of day or offset, or none, for example “YYYY-MM-DDT23:59:60Z”, “YYYY-MM-DDT23:59:60+00:00”, “YYYY-MM-DDT23:59:60” or “23:59:60”.
  • Accepts optional fractional seconds.
  • Accepts every spelling Temporal’s grammar parses: a T, t or space separator, and extended or basic digits, a bare time with or without a T designator, and a designator, annotation or nothing after the second. Temporal silently clamps each of them to :59, so each is a leap second GMT has to catch. A [key=value] annotation value is never read as a time.
  • Compatibility: earlier releases recognised only an uppercase T with extended digits. To keep that narrower test, match /T\d{2}:\d{2}:60(?:[.,]\d+)?[-+Zz[]/ yourself.
ParameterTypeDescription
valuestringISO date-time or time string

true when the string has a second-60 field, otherwise false

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

plain/validate/isLeapSecond.ts