UNPKG

2.59 kBTypeScriptView Raw
1import { Zone } from './zone';
2
3/**
4 * Settings contains static getters and setters that control Luxon's overall behavior.
5 * Luxon is a simple library with few options, but the ones it does have live here.
6 */
7// tslint:disable-next-line:no-unnecessary-class
8export class Settings {
9 /**
10 * Get the callback for returning the current timestamp.
11 */
12 static get now(): () => number;
13
14 /**
15 * Set the callback for returning the current timestamp.
16 * The function should return a number, which will be interpreted as an Epoch millisecond count
17 *
18 * @example Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future
19 * @example Settings.now = () => 0 // always pretend it's Jan 1, 1970 at midnight in UTC time
20 */
21 static set now(now: () => number);
22
23 /**
24 * The default time zone object currently used to create DateTimes. Does not affect existing instances.
25 * The default value is the system's time zone (the one set on the machine that runs this code).
26 * Getting this property always returns a Zone object.
27 */
28 static defaultZone: Zone | string;
29
30 /**
31 * Get the default locale to create DateTimes with. Does not affect existing instances.
32 */
33 static get defaultLocale(): string;
34
35 /**
36 * Set the default locale to create DateTimes with. Does not affect existing instances.
37 */
38 static set defaultLocale(locale: string);
39
40 /**
41 * Get the default numbering system to create DateTimes with. Does not affect existing instances.
42 */
43 static get defaultNumberingSystem(): string;
44
45 /**
46 * Set the default numbering system to create DateTimes with. Does not affect existing instances.
47 */
48 static set defaultNumberingSystem(numberingSystem: string);
49
50 /**
51 * Get the default output calendar to create DateTimes with. Does not affect existing instances.
52 */
53 static get defaultOutputCalendar(): string;
54
55 /**
56 * Set the default output calendar to create DateTimes with. Does not affect existing instances.
57 */
58 static set defaultOutputCalendar(outputCalendar: string);
59
60 /**
61 * Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
62 */
63 static get throwOnInvalid(): boolean;
64
65 /**
66 * Set whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals
67 */
68 static set throwOnInvalid(t: boolean);
69
70 /**
71 * Reset Luxon's global caches. Should only be necessary in testing scenarios.
72 */
73 static resetCaches(): void;
74}