formatHttp
Signature
Section titled “Signature”formatHttp(value: string): stringimport { formatHttp } from "@northguild/gmt/utc/format";Format a UTC ISO 8601 datetime string as an RFC 7231 IMF-fixdate — the
- fixed grammar HTTP headers like
Last-Modified/Date/Expiresrequire. - Fixed grammar, not a display format. RFC 7231 mandates English weekday/month abbreviations and a literal
GMTsuffix regardless of caller locale — there is no locale-appropriate alternative ordering to lose (see roadmapissues/J.mdDecision 1 / J13). - Always
GMT; HTTP-date carries no offset variation to preserve. - Fractional seconds in
valueare truncated — IMF-fixdate has no sub-second field. - Day, hour, minute, and second are always zero-padded to 2 digits; year is zero-padded to 4 digits.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
UTC ISO 8601 datetime string (e.g. “2024-03-15T14:30:00Z”) |
Returns
Section titled “Returns”RFC 7231 IMF-fixdate string, or “” on invalid input
Examples
Section titled “Examples”formatHttp("2024-03-15T14:30:00Z") // "Fri, 15 Mar 2024 14:30:00 GMT"formatHttp("2024-03-15T14:30:00.500Z") // "Fri, 15 Mar 2024 14:30:00 GMT"formatHttp("invalid") // ""