secondsUntilRetryAfter
Signature
Section titled “Signature”secondsUntilRetryAfter(value: string): number | nullReturn the whole seconds to wait from a Retry-After header value.
- Takes the header’s value:
Retry-After = HTTP-date / delay-seconds(RFC 9110 section 10.2.3), anddelay-seconds = 1*DIGIT. - Digits are returned as they are, leading zeros allowed, without reading the clock. A value past the largest safe integer returns null.
- An HTTP-date is read through
parseHttpDate(all three formats) and measured from now, rounded up to a whole second so a wait never falls short. - A past HTTP date gives a negative number. Check
nullfirst, then waitMath.max(0, n):Math.max(0, null)is 0, so an unchecked garbage value means “retry now”. - A
:60leap second returns null, though RFC 9110 section 5.6.7 allows it (itstime-of-daycomment reads “00:00:00 - 23:59:60 (leap second)”): GMT’sparseHttpDaterefuses every second above 59. nullis invalid input only: an empty or unparsable string such as"soon", a sign, a space, a fraction, non-ASCII digits, digits past the largest safe integer, a non-string, or an HTTP-date with a:60second.- No
timeZone: an HTTP-date is always GMT.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | the header’s value: digits, or an HTTP-date |
Returns
Section titled “Returns”the seconds to wait, negative for a past date, or null for anything else
Examples
Section titled “Examples”import { secondsUntilRetryAfter } from "@northguild/gmt/utc/calculate";
secondsUntilRetryAfter("120") // 120 (delay-seconds)Source
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.