| 1 |
import { WeekdayNumbers } from "./datetime"; |
| 2 |
import { Zone, ZoneMaybeValid } from "./zone"; |
| 3 |
|
| 4 |
export interface WeekSettings { |
| 5 |
firstDay: WeekdayNumbers; |
| 6 |
minimalDays: WeekdayNumbers; |
| 7 |
weekend: WeekdayNumbers[]; |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* `Settings` contains static getters and setters that control Luxon's overall behavior. |
| 12 |
* Luxon is a simple library with few options, but the ones it does have live here. |
| 13 |
*/ |
| 14 |
// tslint:disable-next-line:no-unnecessary-class |
| 15 |
export class Settings { |
| 16 |
/** |
| 17 |
* Get the callback for returning the current timestamp. |
| 18 |
*/ |
| 19 |
static get now(): () => number; |
| 20 |
|
| 21 |
/** |
| 22 |
* Set the callback for returning the current timestamp. |
| 23 |
* The function should return a number, which will be interpreted as an Epoch millisecond count |
| 24 |
* |
| 25 |
* @example Settings.now = () => Date.now() + 3000 // pretend it is 3 seconds in the future |
| 26 |
* @example Settings.now = () => 0 // always pretend it is Jan 1, 1970 at midnight in UTC time |
| 27 |
*/ |
| 28 |
static set now(now: () => number); |
| 29 |
|
| 30 |
/** |
| 31 |
* The default time zone object currently used to create DateTimes. Does not affect existing instances. |
| 32 |
* The default value is the system's time zone (the one set on the machine that runs this code). |
| 33 |
*/ |
| 34 |
static get defaultZone(): ZoneMaybeValid; |
| 35 |
static set defaultZone(zone: Zone | string); |
| 36 |
|
| 37 |
/** |
| 38 |
* The default locale to create DateTimes with. Does not affect existing instances. |
| 39 |
*/ |
| 40 |
static defaultLocale: string; |
| 41 |
|
| 42 |
/** |
| 43 |
* The default numbering system to create DateTimes with. Does not affect existing instances. |
| 44 |
*/ |
| 45 |
static defaultNumberingSystem: string; |
| 46 |
|
| 47 |
/** |
| 48 |
* The default output calendar to create DateTimes with. Does not affect existing instances. |
| 49 |
*/ |
| 50 |
static defaultOutputCalendar: string; |
| 51 |
|
| 52 |
/** |
| 53 |
* The cutoff year after which a string encoding a year as two digits is interpreted to occur in the current century. |
| 54 |
*/ |
| 55 |
static twoDigitCutoffYear: number; |
| 56 |
|
| 57 |
/** |
| 58 |
* Whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals |
| 59 |
* |
| 60 |
* If setting this to true, be sure to opt-out of Luxon's invalid return types. |
| 61 |
* @example |
| 62 |
* Settings.throwOnInvalid = true; |
| 63 |
* declare module 'luxon' { |
| 64 |
* interface TSSettings { |
| 65 |
* throwOnInvalid: true; |
| 66 |
* } |
| 67 |
* } |
| 68 |
*/ |
| 69 |
static throwOnInvalid: boolean; |
| 70 |
|
| 71 |
/** |
| 72 |
* Reset Luxon's global caches. Should only be necessary in testing scenarios. |
| 73 |
*/ |
| 74 |
static resetCaches(): void; |
| 75 |
|
| 76 |
/** |
| 77 |
* Allows overriding the default locale week settings, i.e. the start of the week, the weekend and |
| 78 |
* how many days are required in the first week of a year. |
| 79 |
* Does not affect existing instances. |
| 80 |
*/ |
| 81 |
static defaultWeekSettings: WeekSettings | null; |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* TS only settings. Consumers can declaration merge this interface to change TS options. |
| 86 |
* |
| 87 |
* @see Settings.throwOnInvalid |
| 88 |
*/ |
| 89 |
// eslint-disable-next-line @typescript-eslint/no-empty-interface |
| 90 |
export interface TSSettings {} |