spanSeconds
Signature
Section titled “Signature”spanSeconds(start: string, end: string): number | nullReturn the exact elapsed seconds between two ISO 8601 instant strings.
- The same contract as
spanMs, in seconds: signed, fractional and unrounded. - Signed: negative when
startis afterend, sospanSeconds(b, a)is exactly-spanSeconds(a, b). - Measures exact elapsed time, never calendar distance, as
spanMsdoes. A wall-clock day containing a DST transition is 23 or 25 hours, and the hours that elapsed are reported.spanWallClockanswers the calendar question. - Fractional and unrounded. For a wait that must not fall short, write
Math.ceil(n). - Accepts the instant strings
spanMsaccepts: an offset designator (Z,±HH:MM) is required, optionally followed by a bracketed IANA zone. - Returns
nullon invalid input, not0, which is the span between an instant and itself. - Needs no safe-range guard: the widest possible span, 17_280_000_000_000 seconds, is well inside 2^53.
- Leap seconds are not counted (RFC 7519 section 2), as in
spanMs. - For the seconds left until a stored moment, use
secondsUntilHttpDateorsecondsUntilUnix.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start | string | ISO 8601 instant string the span is measured from |
end | string | ISO 8601 instant string the span is measured to |
Returns
Section titled “Returns”exact elapsed seconds, negative when start is after end, or null on invalid input
Examples
Section titled “Examples”import { spanSeconds } from "@northguild/gmt/span/calculate";
spanSeconds("2027-06-15T12:00:00Z", "2027-06-15T12:01:30Z") // 90Source
Section titled “Source”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.