1 | import type { ContextOptions, DateArg, ISOFormatOptions } from "./types.js";
|
2 | /**
|
3 | * The {@link formatISO} function options.
|
4 | */
|
5 | export interface FormatISOOptions
|
6 | extends ISOFormatOptions,
|
7 | ContextOptions<Date> {}
|
8 | /**
|
9 | * @name formatISO
|
10 | * @category Common Helpers
|
11 | * @summary Format the date according to the ISO 8601 standard (https://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003169814.htm).
|
12 | *
|
13 | * @description
|
14 | * Return the formatted date string in ISO 8601 format. Options may be passed to control the parts and notations of the date.
|
15 | *
|
16 | * @param date - The original date
|
17 | * @param options - An object with options.
|
18 | *
|
19 | * @returns The formatted date string (in local time zone)
|
20 | *
|
21 | * @throws `date` must not be Invalid Date
|
22 | *
|
23 | * @example
|
24 | * // Represent 18 September 2019 in ISO 8601 format (local time zone is UTC):
|
25 | * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52))
|
26 | * //=> '2019-09-18T19:00:52Z'
|
27 | *
|
28 | * @example
|
29 | * // Represent 18 September 2019 in ISO 8601, short format (local time zone is UTC):
|
30 | * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })
|
31 | * //=> '20190918T190052'
|
32 | *
|
33 | * @example
|
34 | * // Represent 18 September 2019 in ISO 8601 format, date only:
|
35 | * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })
|
36 | * //=> '2019-09-18'
|
37 | *
|
38 | * @example
|
39 | * // Represent 18 September 2019 in ISO 8601 format, time only (local time zone is UTC):
|
40 | * const result = formatISO(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })
|
41 | * //=> '19:00:52Z'
|
42 | */
|
43 | export declare function formatISO(
|
44 | date: DateArg<Date> & {},
|
45 | options?: FormatISOOptions,
|
46 | ): string;
|