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. --- .../node_modules/luxon/src/zones/IANAZone.js | 72 +++++++++++----------- .../luxon/src/zones/fixedOffsetZone.js | 10 ++- .../node_modules/luxon/src/zones/invalidZone.js | 2 +- .../node_modules/luxon/src/zones/localZone.js | 63 ------------------- .../node_modules/luxon/src/zones/systemZone.js | 61 ++++++++++++++++++ 5 files changed, 106 insertions(+), 102 deletions(-) delete mode 100644 npm_assets/node_modules/luxon/src/zones/localZone.js create mode 100644 npm_assets/node_modules/luxon/src/zones/systemZone.js (limited to 'npm_assets/node_modules/luxon/src/zones') diff --git a/npm_assets/node_modules/luxon/src/zones/IANAZone.js b/npm_assets/node_modules/luxon/src/zones/IANAZone.js index 777958d..ad59451 100644 --- a/npm_assets/node_modules/luxon/src/zones/IANAZone.js +++ b/npm_assets/node_modules/luxon/src/zones/IANAZone.js @@ -1,8 +1,6 @@ -import { formatOffset, parseZoneInfo, isUndefined, ianaRegex, objToLocalTS } from "../impl/util.js"; +import { formatOffset, parseZoneInfo, isUndefined, objToLocalTS } from "../impl/util.js"; import Zone from "../zone.js"; -const matchingRegex = RegExp(`^${ianaRegex.source}$`); - let dtfCache = {}; function makeDTF(zone) { if (!dtfCache[zone]) { @@ -14,7 +12,8 @@ function makeDTF(zone) { day: "2-digit", hour: "2-digit", minute: "2-digit", - second: "2-digit" + second: "2-digit", + era: "short", }); } return dtfCache[zone]; @@ -24,26 +23,29 @@ const typeToPos = { year: 0, month: 1, day: 2, - hour: 3, - minute: 4, - second: 5 + era: 3, + hour: 4, + minute: 5, + second: 6, }; function hackyOffset(dtf, date) { const formatted = dtf.format(date).replace(/\u200E/g, ""), - parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted), - [, fMonth, fDay, fYear, fHour, fMinute, fSecond] = parsed; - return [fYear, fMonth, fDay, fHour, fMinute, fSecond]; + parsed = /(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(formatted), + [, fMonth, fDay, fYear, fadOrBc, fHour, fMinute, fSecond] = parsed; + return [fYear, fMonth, fDay, fadOrBc, fHour, fMinute, fSecond]; } function partsOffset(dtf, date) { - const formatted = dtf.formatToParts(date), - filled = []; + const formatted = dtf.formatToParts(date); + const filled = []; for (let i = 0; i < formatted.length; i++) { - const { type, value } = formatted[i], - pos = typeToPos[type]; + const { type, value } = formatted[i]; + const pos = typeToPos[type]; - if (!isUndefined(pos)) { + if (type === "era") { + filled[pos] = value; + } else if (!isUndefined(pos)) { filled[pos] = parseInt(value, 10); } } @@ -80,12 +82,12 @@ export default class IANAZone extends Zone { * Returns whether the provided string is a valid specifier. This only checks the string's format, not that the specifier identifies a known zone; see isValidZone for that. * @param {string} s - The string to check validity on * @example IANAZone.isValidSpecifier("America/New_York") //=> true - * @example IANAZone.isValidSpecifier("Fantasia/Castle") //=> true * @example IANAZone.isValidSpecifier("Sport~~blorp") //=> false + * @deprecated This method returns false for some valid IANA names. Use isValidZone instead. * @return {boolean} */ static isValidSpecifier(s) { - return !!(s && s.match(matchingRegex)); + return this.isValidZone(s); } /** @@ -97,6 +99,9 @@ export default class IANAZone extends Zone { * @return {boolean} */ static isValidZone(zone) { + if (!zone) { + return false; + } try { new Intl.DateTimeFormat("en-US", { timeZone: zone }).format(); return true; @@ -105,18 +110,6 @@ export default class IANAZone extends Zone { } } - // Etc/GMT+8 -> -480 - /** @ignore */ - static parseGMTOffset(specifier) { - if (specifier) { - const match = specifier.match(/^Etc\/GMT(0|[+-]\d{1,2})$/i); - if (match) { - return -60 * parseInt(match[1]); - } - } - return null; - } - constructor(name) { super(); /** @private **/ @@ -136,7 +129,7 @@ export default class IANAZone extends Zone { } /** @override **/ - get universal() { + get isUniversal() { return false; } @@ -156,12 +149,17 @@ export default class IANAZone extends Zone { if (isNaN(date)) return NaN; - const dtf = makeDTF(this.name), - [year, month, day, hour, minute, second] = dtf.formatToParts - ? partsOffset(dtf, date) - : hackyOffset(dtf, date), - // work around https://bugs.chromium.org/p/chromium/issues/detail?id=1025564&can=2&q=%2224%3A00%22%20datetimeformat - adjustedHour = hour === 24 ? 0 : hour; + const dtf = makeDTF(this.name); + let [year, month, day, adOrBc, hour, minute, second] = dtf.formatToParts + ? partsOffset(dtf, date) + : hackyOffset(dtf, date); + + if (adOrBc === "BC") { + year = -Math.abs(year) + 1; + } + + // because we're using hour12 and https://bugs.chromium.org/p/chromium/issues/detail?id=1025564&can=2&q=%2224%3A00%22%20datetimeformat + const adjustedHour = hour === 24 ? 0 : hour; const asUTC = objToLocalTS({ year, @@ -170,7 +168,7 @@ export default class IANAZone extends Zone { hour: adjustedHour, minute, second, - millisecond: 0 + millisecond: 0, }); let asTS = +date; diff --git a/npm_assets/node_modules/luxon/src/zones/fixedOffsetZone.js b/npm_assets/node_modules/luxon/src/zones/fixedOffsetZone.js index 364e065..dcfa25a 100644 --- a/npm_assets/node_modules/luxon/src/zones/fixedOffsetZone.js +++ b/npm_assets/node_modules/luxon/src/zones/fixedOffsetZone.js @@ -62,6 +62,14 @@ export default class FixedOffsetZone extends Zone { return this.fixed === 0 ? "UTC" : `UTC${formatOffset(this.fixed, "narrow")}`; } + get ianaName() { + if (this.fixed === 0) { + return "Etc/UTC"; + } else { + return `Etc/GMT${formatOffset(-this.fixed, "narrow")}`; + } + } + /** @override **/ offsetName() { return this.name; @@ -73,7 +81,7 @@ export default class FixedOffsetZone extends Zone { } /** @override **/ - get universal() { + get isUniversal() { return true; } diff --git a/npm_assets/node_modules/luxon/src/zones/invalidZone.js b/npm_assets/node_modules/luxon/src/zones/invalidZone.js index d7b7104..9a1a2d4 100644 --- a/npm_assets/node_modules/luxon/src/zones/invalidZone.js +++ b/npm_assets/node_modules/luxon/src/zones/invalidZone.js @@ -22,7 +22,7 @@ export default class InvalidZone extends Zone { } /** @override **/ - get universal() { + get isUniversal() { return false; } diff --git a/npm_assets/node_modules/luxon/src/zones/localZone.js b/npm_assets/node_modules/luxon/src/zones/localZone.js deleted file mode 100644 index dae9b2a..0000000 --- a/npm_assets/node_modules/luxon/src/zones/localZone.js +++ /dev/null @@ -1,63 +0,0 @@ -import { formatOffset, parseZoneInfo, hasIntl } from "../impl/util.js"; -import Zone from "../zone.js"; - -let singleton = null; - -/** - * Represents the local zone for this JavaScript environment. - * @implements {Zone} - */ -export default class LocalZone extends Zone { - /** - * Get a singleton instance of the local zone - * @return {LocalZone} - */ - static get instance() { - if (singleton === null) { - singleton = new LocalZone(); - } - return singleton; - } - - /** @override **/ - get type() { - return "local"; - } - - /** @override **/ - get name() { - if (hasIntl()) { - return new Intl.DateTimeFormat().resolvedOptions().timeZone; - } else return "local"; - } - - /** @override **/ - get universal() { - return false; - } - - /** @override **/ - offsetName(ts, { format, locale }) { - return parseZoneInfo(ts, format, locale); - } - - /** @override **/ - formatOffset(ts, format) { - return formatOffset(this.offset(ts), format); - } - - /** @override **/ - offset(ts) { - return -new Date(ts).getTimezoneOffset(); - } - - /** @override **/ - equals(otherZone) { - return otherZone.type === "local"; - } - - /** @override **/ - get isValid() { - return true; - } -} diff --git a/npm_assets/node_modules/luxon/src/zones/systemZone.js b/npm_assets/node_modules/luxon/src/zones/systemZone.js new file mode 100644 index 0000000..533e663 --- /dev/null +++ b/npm_assets/node_modules/luxon/src/zones/systemZone.js @@ -0,0 +1,61 @@ +import { formatOffset, parseZoneInfo } from "../impl/util.js"; +import Zone from "../zone.js"; + +let singleton = null; + +/** + * Represents the local zone for this JavaScript environment. + * @implements {Zone} + */ +export default class SystemZone extends Zone { + /** + * Get a singleton instance of the local zone + * @return {SystemZone} + */ + static get instance() { + if (singleton === null) { + singleton = new SystemZone(); + } + return singleton; + } + + /** @override **/ + get type() { + return "system"; + } + + /** @override **/ + get name() { + return new Intl.DateTimeFormat().resolvedOptions().timeZone; + } + + /** @override **/ + get isUniversal() { + return false; + } + + /** @override **/ + offsetName(ts, { format, locale }) { + return parseZoneInfo(ts, format, locale); + } + + /** @override **/ + formatOffset(ts, format) { + return formatOffset(this.offset(ts), format); + } + + /** @override **/ + offset(ts) { + return -new Date(ts).getTimezoneOffset(); + } + + /** @override **/ + equals(otherZone) { + return otherZone.type === "system"; + } + + /** @override **/ + get isValid() { + return true; + } +} -- cgit v1.2.3