formatRfc2822
Signature
Section titled “Signature”formatRfc2822(value: string): stringimport { formatRfc2822 } from "@northguild/gmt/zoned/format";Format a zoned ISO 8601 datetime string as an RFC 5322 (RFC 2822) date-time
- — the fixed grammar email
Date:headers require. - Fixed grammar, not a display format. RFC 5322 mandates English weekday/month abbreviations and a numeric
+HHMM/-HHMMoffset regardless of caller locale — there is no locale-appropriate alternative ordering to lose, so this does not conflict with Decision 1’s exclusion of a general token formatter (see roadmapissues/J.md, J13). - Uses the input’s own UTC offset at that instant (DST-aware); never emits an obsolete named zone like “GMT” or “EST” on output, only numeric.
- 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 |
zoned ISO 8601 datetime string (e.g. “2024-03-15T14:30:00-04:00[America/New_York]”) |
Returns
Section titled “Returns”RFC 5322 date-time string, or “” on invalid input
Examples
Section titled “Examples”formatRfc2822("2024-03-15T14:30:00-04:00[America/New_York]") // "Fri, 15 Mar 2024 14:30:00 -0400"formatRfc2822("2024-01-05T09:00:00+00:00[UTC]") // "Fri, 05 Jan 2024 09:00:00 +0000"formatRfc2822("invalid") // ""