From 9b0e86a8e74768c4fe848fb5ce8d754292db4e3e Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Tue, 23 Apr 2024 00:37:58 -0400 Subject: New upstream version 8.3.0. --- npm_assets/node_modules/luxon/src/settings.js | 49 ++++++++++++++++----------- 1 file changed, 30 insertions(+), 19 deletions(-) (limited to 'npm_assets/node_modules/luxon/src/settings.js') 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. @@ -34,32 +35,22 @@ export default class Settings { now = n; } - /** - * 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); } /** @@ -110,6 +101,26 @@ export default class Settings { defaultOutputCalendar = outputCalendar; } + /** + * 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} -- cgit v1.2.3