|
1 | 1 | export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'; |
2 | 2 |
|
3 | 3 | export interface DateAdapter { |
4 | | - // Override one or multiple of the methods to adjust to the logic of the current date library. |
5 | | - override(members: Partial<DateAdapter>): void; |
6 | | - readonly options: unknown; |
| 4 | + // Override one or multiple of the methods to adjust to the logic of the current date library. |
| 5 | + override(members: Partial<DateAdapter>): void; |
| 6 | + readonly options: unknown; |
7 | 7 |
|
8 | | - /** |
9 | | - * Returns a map of time formats for the supported formatting units defined |
10 | | - * in Unit as well as 'datetime' representing a detailed date/time string. |
11 | | - * @returns {{string: string}} |
12 | | - */ |
13 | | - formats(): { [key: string]: string }; |
14 | | - /** |
15 | | - * Parses the given `value` and return the associated timestamp. |
16 | | - * @param {unknown} value - the value to parse (usually comes from the data) |
17 | | - * @param {string} [format] - the expected data format |
18 | | - */ |
19 | | - parse(value: unknown, format?: TimeUnit): number | null; |
20 | | - /** |
21 | | - * Returns the formatted date in the specified `format` for a given `timestamp`. |
22 | | - * @param {number} timestamp - the timestamp to format |
23 | | - * @param {string} format - the date/time token |
24 | | - * @return {string} |
25 | | - */ |
26 | | - format(timestamp: number, format: TimeUnit): string; |
27 | | - /** |
28 | | - * Adds the specified `amount` of `unit` to the given `timestamp`. |
29 | | - * @param {number} timestamp - the input timestamp |
30 | | - * @param {number} amount - the amount to add |
31 | | - * @param {Unit} unit - the unit as string |
32 | | - * @return {number} |
33 | | - */ |
34 | | - add(timestamp: number, amount: number, unit: TimeUnit): number; |
35 | | - /** |
36 | | - * Returns the number of `unit` between the given timestamps. |
37 | | - * @param {number} a - the input timestamp (reference) |
38 | | - * @param {number} b - the timestamp to subtract |
39 | | - * @param {Unit} unit - the unit as string |
40 | | - * @return {number} |
41 | | - */ |
42 | | - diff(a: number, b: number, unit: TimeUnit): number; |
43 | | - /** |
44 | | - * Returns start of `unit` for the given `timestamp`. |
45 | | - * @param {number} timestamp - the input timestamp |
46 | | - * @param {Unit|'isoWeek'} unit - the unit as string |
47 | | - * @param {number} [weekday] - the ISO day of the week with 1 being Monday |
48 | | - * and 7 being Sunday (only needed if param *unit* is `isoWeek`). |
49 | | - * @return {number} |
50 | | - */ |
51 | | - startOf(timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number; |
52 | | - /** |
53 | | - * Returns end of `unit` for the given `timestamp`. |
54 | | - * @param {number} timestamp - the input timestamp |
55 | | - * @param {Unit|'isoWeek'} unit - the unit as string |
56 | | - * @return {number} |
57 | | - */ |
58 | | - endOf(timestamp: number, unit: TimeUnit | 'isoWeek'): number; |
| 8 | + /** |
| 9 | + * Returns a map of time formats for the supported formatting units defined |
| 10 | + * in Unit as well as 'datetime' representing a detailed date/time string. |
| 11 | + * @returns {{string: string}} |
| 12 | + */ |
| 13 | + formats(): { [key: string]: string }; |
| 14 | + /** |
| 15 | + * Parses the given `value` and return the associated timestamp. |
| 16 | + * @param {unknown} value - the value to parse (usually comes from the data) |
| 17 | + * @param {string} [format] - the expected data format |
| 18 | + */ |
| 19 | + parse(value: unknown, format?: TimeUnit): number | null; |
| 20 | + /** |
| 21 | + * Returns the formatted date in the specified `format` for a given `timestamp`. |
| 22 | + * @param {number} timestamp - the timestamp to format |
| 23 | + * @param {string} format - the date/time token |
| 24 | + * @return {string} |
| 25 | + */ |
| 26 | + format(timestamp: number, format: TimeUnit): string; |
| 27 | + /** |
| 28 | + * Adds the specified `amount` of `unit` to the given `timestamp`. |
| 29 | + * @param {number} timestamp - the input timestamp |
| 30 | + * @param {number} amount - the amount to add |
| 31 | + * @param {Unit} unit - the unit as string |
| 32 | + * @return {number} |
| 33 | + */ |
| 34 | + add(timestamp: number, amount: number, unit: TimeUnit): number; |
| 35 | + /** |
| 36 | + * Returns the number of `unit` between the given timestamps. |
| 37 | + * @param {number} a - the input timestamp (reference) |
| 38 | + * @param {number} b - the timestamp to subtract |
| 39 | + * @param {Unit} unit - the unit as string |
| 40 | + * @return {number} |
| 41 | + */ |
| 42 | + diff(a: number, b: number, unit: TimeUnit): number; |
| 43 | + /** |
| 44 | + * Returns start of `unit` for the given `timestamp`. |
| 45 | + * @param {number} timestamp - the input timestamp |
| 46 | + * @param {Unit|'isoWeek'} unit - the unit as string |
| 47 | + * @param {number} [weekday] - the ISO day of the week with 1 being Monday |
| 48 | + * and 7 being Sunday (only needed if param *unit* is `isoWeek`). |
| 49 | + * @return {number} |
| 50 | + */ |
| 51 | + startOf(timestamp: number, unit: TimeUnit | 'isoWeek', weekday?: number): number; |
| 52 | + /** |
| 53 | + * Returns end of `unit` for the given `timestamp`. |
| 54 | + * @param {number} timestamp - the input timestamp |
| 55 | + * @param {Unit|'isoWeek'} unit - the unit as string |
| 56 | + * @return {number} |
| 57 | + */ |
| 58 | + endOf(timestamp: number, unit: TimeUnit | 'isoWeek'): number; |
59 | 59 | } |
60 | 60 |
|
61 | 61 | export const _adapters: { |
62 | | - _date: DateAdapter; |
| 62 | + _date: DateAdapter; |
63 | 63 | }; |
0 commit comments