@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.
26 lines • 1.72 kB
TypeScript
import { Temporal } from "./temporal.js";
export declare const ENGLISH_WEEKDAY_NAMES: readonly ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
export declare const ENGLISH_MONTH_NAMES: readonly ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
/**
* The `Mon, 15 Jul 2024 12:00:00` stem RFC 5322 date-time and RFC 9110 IMF-fixdate share: English
* day and month names, zero-padded fields, read from the date-time's own wall clock.
*
* @param zdt the date-time; the caller has already rejected a year its grammar cannot hold: a
* negative one for RFC 5322 (`year = 4*DIGIT`, so five digits are written in full), and any
* outside 0000–9999 for RFC 9110 (`year = 4DIGIT`)
* @returns the stem, without a zone or `GMT` suffix
* @example englishDateTimeStem(Temporal.ZonedDateTime.from("2024-07-15T12:00:05+00:00[UTC]")) // "Mon, 15 Jul 2024 12:00:05"
* @example englishDateTimeStem(Temporal.ZonedDateTime.from("0099-01-03T04:05:06+00:00[UTC]")) // "Sat, 03 Jan 0099 04:05:06"
*/
export declare function englishDateTimeStem(zdt: Temporal.ZonedDateTime): string;
/**
* The RFC 9110 §5.6.7 IMF-fixdate for a UTC value, such as `Fri, 15 Mar 2024 14:30:00 GMT`.
*
* The caller passes a value already on the UTC clock; sub-second digits are not written.
*
* @param utc a zoned date-time in UTC
* @returns the HTTP-date, or `""` for a year outside 0000–9999 (`year = 4DIGIT`)
* @example imfFixdate(Temporal.ZonedDateTime.from("2024-03-15T14:30:00+00:00[UTC]")) // "Fri, 15 Mar 2024 14:30:00 GMT"
* @example imfFixdate(Temporal.ZonedDateTime.from("-000001-06-15T12:00:00+00:00[UTC]")) // ""
*/
export declare function imfFixdate(utc: Temporal.ZonedDateTime): string;