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.

36 lines • 1.58 kB
import { Temporal } from "./temporal.js"; /** Date-time fields read from an RFC 9110 HTTP-date, before calendar validation. */ export interface HttpDateFields { /** ISO day of week 1 (Monday) – 7 (Sunday). */ dayOfWeek: number; year: number; month: number; day: number; hour: number; minute: number; second: number; } /** * Read the fields of an RFC 9110 obsolete HTTP-date: `rfc850-date` or * `asctime-date`. IMF-fixdate is read with the exported `httpDate` pattern. * * - Shape checks only: the calendar date and the day of week are left to the * caller (`Temporal.PlainDateTime.from` with `overflow: "reject"`). * - An `rfc850-date` reads the clock (`nowInstant()`) to place its * two-digit year; that call throws if the clock cannot be read. * * @param value candidate obsolete HTTP-date * @returns the fields, or `null` when `value` is neither obsolete format */ export declare function readObsoleteHttpDate(value: string): HttpDateFields | null; /** * The core of `parseHttpDate`, `isValidHttpDate`, `secondsUntilHttpDate` and * `secondsUntilRetryAfter`: the instant an HTTP-date names. Never throws. * * @param value an HTTP-date (IMF-fixdate, or one of the obsolete RFC 850 and asctime forms) * @returns the instant, or `null` when `value` is not a real HTTP-date or names the wrong weekday * * @example httpDateInstantOf("Fri, 15 Mar 2024 12:30:45 GMT") // 2024-03-15T12:30:45Z * @example httpDateInstantOf("Sat, 15 Mar 2024 12:30:45 GMT") // null */ export declare function httpDateInstantOf(value: unknown): Temporal.Instant | null;