UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

37 lines • 1.55 kB
/** Date-time fields read from an RFC 5322 `date-time`, before calendar validation. */ export interface Rfc5322DateTimeFields { /** ISO day of week 1 (Monday) – 7 (Sunday), when the input names one. */ dayOfWeek: number | undefined; year: number; month: number; day: number; hour: number; minute: number; second: number; /** `±HH:MM`; `-0000` and every zone RFC 5322 maps to it are `+00:00`. */ offset: string; } /** * Read the fields of an RFC 5322 `date-time` as a conformant receiver must: * the §3.3 syntax plus the §4 obsolete syntax (CFWS between tokens, 2- and * 3-digit years, alphabetic zones), with case-insensitive names. * * - Shape and name checks only: the calendar date, the time of day and the * day of week are left to the caller (`Temporal.PlainDateTime.from` with * `overflow: "reject"`). * * @param value candidate RFC 5322 date-time * @returns the fields, or `null` when `value` is not a `date-time` */ export declare function readRfc5322DateTime(value: string): Rfc5322DateTimeFields | null; /** * The core of `parseRfc2822` and `isValidRfc2822DateTime`: the zoned date-time an RFC 2822 * date-time names. Never throws. * * @param value an RFC 2822 date-time * @returns an ISO 8601 zoned string, or `""` when `value` is not a valid RFC 2822 date-time * * @example readRfc2822("Fri, 15 Mar 2024 12:30:45 +0100") // "2024-03-15T12:30:45+01:00[+01:00]" * @example readRfc2822("Sat, 15 Mar 2024 12:30:45 +0100") // "" */ export declare function readRfc2822(value: string): string;