aboutsummaryrefslogtreecommitdiffstats
path: root/npm_assets/node_modules/luxon/src/zones
diff options
context:
space:
mode:
Diffstat (limited to 'npm_assets/node_modules/luxon/src/zones')
-rw-r--r--npm_assets/node_modules/luxon/src/zones/IANAZone.js72
-rw-r--r--npm_assets/node_modules/luxon/src/zones/fixedOffsetZone.js10
-rw-r--r--npm_assets/node_modules/luxon/src/zones/invalidZone.js2
-rw-r--r--npm_assets/node_modules/luxon/src/zones/systemZone.js (renamed from npm_assets/node_modules/luxon/src/zones/localZone.js)18
4 files changed, 53 insertions, 49 deletions
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/systemZone.js
index dae9b2a..533e663 100644
--- a/npm_assets/node_modules/luxon/src/zones/localZone.js
+++ b/npm_assets/node_modules/luxon/src/zones/systemZone.js
@@ -1,4 +1,4 @@
-import { formatOffset, parseZoneInfo, hasIntl } from "../impl/util.js";
+import { formatOffset, parseZoneInfo } from "../impl/util.js";
import Zone from "../zone.js";
let singleton = null;
@@ -7,32 +7,30 @@ let singleton = null;
* Represents the local zone for this JavaScript environment.
* @implements {Zone}
*/
-export default class LocalZone extends Zone {
+export default class SystemZone extends Zone {
/**
* Get a singleton instance of the local zone
- * @return {LocalZone}
+ * @return {SystemZone}
*/
static get instance() {
if (singleton === null) {
- singleton = new LocalZone();
+ singleton = new SystemZone();
}
return singleton;
}
/** @override **/
get type() {
- return "local";
+ return "system";
}
/** @override **/
get name() {
- if (hasIntl()) {
- return new Intl.DateTimeFormat().resolvedOptions().timeZone;
- } else return "local";
+ return new Intl.DateTimeFormat().resolvedOptions().timeZone;
}
/** @override **/
- get universal() {
+ get isUniversal() {
return false;
}
@@ -53,7 +51,7 @@ export default class LocalZone extends Zone {
/** @override **/
equals(otherZone) {
- return otherZone.type === "local";
+ return otherZone.type === "system";
}
/** @override **/