MCPcopy
hub / github.com/chartjs/Chart.js / DateAdapter

Interface DateAdapter

src/core/core.adapters.ts:12–63  ·  src/core/core.adapters.ts::DateAdapter

Source from the content-addressed store, hash-verified

10export type TimeUnit = class="st">'millisecond' | class="st">'second' | class="st">'minute' | class="st">'hour' | class="st">'day' | class="st">'week' | class="st">'month' | class="st">'quarter' | class="st">'year';
11
12export interface DateAdapter<T extends AnyObject = AnyObject> {
13 readonly options: T;
14 /**
15 * Will called with chart options after adapter creation.
16 */
17 init(this: DateAdapter<T>, chartOptions: ChartOptions): void;
18 /**
19 * Returns a map of time formats for the supported formatting units defined
20 * in Unit as well as class="st">'datetime' representing a detailed date/time string.
21 */
22 formats(this: DateAdapter<T>): Record<TimeUnit | class="st">'datetime', string>;
23 /**
24 * Parses the given `value` and return the associated timestamp.
25 * @param value - the value to parse (usually comes from the data)
26 * @param [format] - the expected data format
27 */
28 parse(this: DateAdapter<T>, value: unknown, format?: string): number | null;
29 /**
30 * Returns the formatted date in the specified `format` for a given `timestamp`.
31 * @param timestamp - the timestamp to format
32 * @param format - the date/time token
33 */
34 format(this: DateAdapter<T>, timestamp: number, format: string): string;
35 /**
36 * Adds the specified `amount` of `unit` to the given `timestamp`.
37 * @param timestamp - the input timestamp
38 * @param amount - the amount to add
39 * @param unit - the unit as string
40 */
41 add(this: DateAdapter<T>, timestamp: number, amount: number, unit: TimeUnit): number;
42 /**
43 * Returns the number of `unit` between the given timestamps.
44 * @param a - the input timestamp (reference)
45 * @param b - the timestamp to subtract
46 * @param unit - the unit as string
47 */
48 diff(this: DateAdapter<T>, a: number, b: number, unit: TimeUnit): number;
49 /**
50 * Returns start of `unit` for the given `timestamp`.
51 * @param timestamp - the input timestamp
52 * @param unit - the unit as string
53 * @param [weekday] - the ISO day of the week with 1 being Monday
54 * and 7 being Sunday (only needed if param *unit* is `isoWeek`).
55 */
56 startOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit | class="st">'isoWeek', weekday?: number | boolean): number;
57 /**
58 * Returns end of `unit` for the given `timestamp`.
59 * @param timestamp - the input timestamp
60 * @param unit - the unit as string
61 */
62 endOf(this: DateAdapter<T>, timestamp: number, unit: TimeUnit): number;
63}
64
65function abstract<T = void>(): T {
66 throw new Error(class="st">'This method is not implemented: Check that a complete date adapter is provided.');

Callers 24

buildOrUpdateScalesMethod · 0.65
initMethod · 0.65
parseFloatBarFunction · 0.65
parseValueFunction · 0.65
parseArrayOrPrimitiveFunction · 0.65
parseObjectDataMethod · 0.65
parsePrimitiveDataMethod · 0.65
parseArrayDataMethod · 0.65
parseObjectDataMethod · 0.65
registerMethod · 0.65
updateMethod · 0.65
cachedKeysFunction · 0.65

Implementers 1

DateAdapterBasesrc/core/core.adapters.ts

Calls

no outgoing calls

Tested by

no test coverage detected