diff options
Diffstat (limited to 'npm_assets/node_modules/luxon/src/settings.js')
| -rw-r--r-- | npm_assets/node_modules/luxon/src/settings.js | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/npm_assets/node_modules/luxon/src/settings.js b/npm_assets/node_modules/luxon/src/settings.js index 57f68e9..e119e97 100644 --- a/npm_assets/node_modules/luxon/src/settings.js +++ b/npm_assets/node_modules/luxon/src/settings.js @@ -1,15 +1,16 @@ -import LocalZone from "./zones/localZone.js"; +import SystemZone from "./zones/systemZone.js"; import IANAZone from "./zones/IANAZone.js"; import Locale from "./impl/locale.js"; import { normalizeZone } from "./impl/zoneUtil.js"; let now = () => Date.now(), - defaultZone = null, // not setting this directly to LocalZone.instance bc loading order issues + defaultZone = "system", defaultLocale = null, defaultNumberingSystem = null, defaultOutputCalendar = null, - throwOnInvalid = false; + twoDigitCutoffYear = 60, + throwOnInvalid; /** * Settings contains static getters and setters that control Luxon's overall behavior. Luxon is a simple library with few options, but the ones it does have live here. @@ -35,31 +36,21 @@ export default class Settings { } /** - * Get the default time zone to create DateTimes in. - * @type {string} - */ - static get defaultZoneName() { - return Settings.defaultZone.name; - } - - /** * Set the default time zone to create DateTimes in. Does not affect existing instances. + * Use the value "system" to reset this value to the system's time zone. * @type {string} */ - static set defaultZoneName(z) { - if (!z) { - defaultZone = null; - } else { - defaultZone = normalizeZone(z); - } + static set defaultZone(zone) { + defaultZone = zone; } /** - * Get the default time zone object to create DateTimes in. Does not affect existing instances. + * Get the default time zone object currently used to create DateTimes. Does not affect existing instances. + * The default value is the system's time zone (the one set on the machine that runs this code). * @type {Zone} */ static get defaultZone() { - return defaultZone || LocalZone.instance; + return normalizeZone(defaultZone, SystemZone.instance); } /** @@ -111,6 +102,26 @@ export default class Settings { } /** + * Get the cutoff year after which a string encoding a year as two digits is interpreted to occur in the current century. + * @type {number} + */ + static get twoDigitCutoffYear() { + return twoDigitCutoffYear; + } + + /** + * Set the cutoff year after which a string encoding a year as two digits is interpreted to occur in the current century. + * @type {number} + * @example Settings.twoDigitCutoffYear = 0 // cut-off year is 0, so all 'yy' are interpretted as current century + * @example Settings.twoDigitCutoffYear = 50 // '49' -> 1949; '50' -> 2050 + * @example Settings.twoDigitCutoffYear = 1950 // interpretted as 50 + * @example Settings.twoDigitCutoffYear = 2050 // ALSO interpretted as 50 + */ + static set twoDigitCutoffYear(cutoffYear) { + twoDigitCutoffYear = cutoffYear % 100; + } + + /** * Get whether Luxon will throw when it encounters invalid DateTimes, Durations, or Intervals * @type {boolean} */ |
