isValidHttpDate
Signature
Section titled “Signature”isValidHttpDate(value: string): booleanisValidHttpDate(value: void | {} | null | undefined): booleanisValidHttpDate(value: unknown): value is stringReturn true when value is a real HTTP header date: the RFC 9110 §5.6.7 HTTP-date that headers like Last-Modified, Date and Expires carry, such as Fri, 15 Mar 2024 14:30:00 GMT.
- True exactly when
parseHttpDatereturns a UTC string for the same value: the validator calls the parser, so the two cannot disagree. - All three HTTP-date formats, which RFC 9110 §5.6.7 says a recipient “MUST accept”: IMF-fixdate, and the obsolete rfc850-date (
Sunday, 06-Nov-94 08:49:37 GMT) and asctime-date (Sun Nov 6 08:49:37 1994). ThehttpDatepattern matches IMF-fixdate alone. - Checks the calendar as well as the shape. The pattern matches a day that does not exist:
31 Feb,29 Feb 2023and31 Junare false here. - The day name must match the date, in all three formats. The pattern does not check it.
- False for an hour above 23 and a minute above 59, which the pattern matches. False for a second of 60: GMT rejects leap seconds.
- HTTP-date is case-sensitive and fixed-width, and its zone is the literal
GMT: a numeric offset is false. - An rfc850-date reads the clock. Its two-digit year is read against the current instant (
Temporal.Now.instant()), asparseHttpDatedescribes, so the same string can change its answer decades apart; if the clock cannot be read the answer is false. The other two formats never read the clock. - A value that is not a string, a
Stringobject included, returnsfalse. Atrueresult narrows anunknownvalue tostring. - Read the value with
parseHttpDate; write one withformatHttpDate.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | any value; a string is checked as an RFC 9110 HTTP-date |
Returns
Section titled “Returns”boolean indicating validity
Examples
Section titled “Examples”import { isValidHttpDate } from "@northguild/gmt/utc/validate";
isValidHttpDate("Fri, 15 Mar 2024 14:30:00 GMT") // trueSource
Section titled “Source”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.