UNPKG

2.03 kBTypeScriptView Raw
1/**
2 * Builds a proper UTC HttpDate timestamp from a Date object
3 * since not all environments will have this as the expected
4 * format.
5 *
6 * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString
7 * > Prior to ECMAScript 2018, the format of the return value
8 * > varied according to the platform. The most common return
9 * > value was an RFC-1123 formatted date stamp, which is a
10 * > slightly updated version of RFC-822 date stamps.
11 */
12export declare function dateToUtcString(date: Date): string;
13/**
14 * Parses a value into a Date. Returns undefined if the input is null or
15 * undefined, throws an error if the input is not a string that can be parsed
16 * as an RFC 3339 date.
17 *
18 * Input strings must conform to RFC3339 section 5.6, and cannot have a UTC
19 * offset. Fractional precision is supported.
20 *
21 * {@see https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14}
22 *
23 * @param value the value to parse
24 * @return a Date or undefined
25 */
26export declare const parseRfc3339DateTime: (value: unknown) => Date | undefined;
27/**
28 * Parses a value into a Date. Returns undefined if the input is null or
29 * undefined, throws an error if the input is not a string that can be parsed
30 * as an RFC 7231 IMF-fixdate or obs-date.
31 *
32 * Input strings must conform to RFC7231 section 7.1.1.1. Fractional seconds are supported.
33 *
34 * {@see https://datatracker.ietf.org/doc/html/rfc7231.html#section-7.1.1.1}
35 *
36 * @param value the value to parse
37 * @return a Date or undefined
38 */
39export declare const parseRfc7231DateTime: (value: unknown) => Date | undefined;
40/**
41 * Parses a value into a Date. Returns undefined if the input is null or
42 * undefined, throws an error if the input is not a number or a parseable string.
43 *
44 * Input strings must be an integer or floating point number. Fractional seconds are supported.
45 *
46 * @param value the value to parse
47 * @return a Date or undefined
48 */
49export declare const parseEpochTimestamp: (value: unknown) => Date | undefined;