aboutsummaryrefslogtreecommitdiffstats
path: root/npm_assets/node_modules/luxon/src
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2024-04-23 00:37:58 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2024-04-23 00:37:58 -0400
commit9b0e86a8e74768c4fe848fb5ce8d754292db4e3e (patch)
treecfd424be8ecb68357e6e572033f08bc534bf724f /npm_assets/node_modules/luxon/src
parent393aa58f2c5afd51f92fd9bd4b6dfd0dc90cea41 (diff)
New upstream version 8.3.0.upstream/8.3.0upstream
Diffstat (limited to 'npm_assets/node_modules/luxon/src')
-rw-r--r--npm_assets/node_modules/luxon/src/datetime.js635
-rw-r--r--npm_assets/node_modules/luxon/src/duration.js376
-rw-r--r--npm_assets/node_modules/luxon/src/impl/conversions.js32
-rw-r--r--npm_assets/node_modules/luxon/src/impl/diff.js29
-rw-r--r--npm_assets/node_modules/luxon/src/impl/digits.js5
-rw-r--r--npm_assets/node_modules/luxon/src/impl/english.js14
-rw-r--r--npm_assets/node_modules/luxon/src/impl/formats.js63
-rw-r--r--npm_assets/node_modules/luxon/src/impl/formatter.js54
-rw-r--r--npm_assets/node_modules/luxon/src/impl/locale.js218
-rw-r--r--npm_assets/node_modules/luxon/src/impl/regexParser.js122
-rw-r--r--npm_assets/node_modules/luxon/src/impl/tokenParser.js112
-rw-r--r--npm_assets/node_modules/luxon/src/impl/util.js76
-rw-r--r--npm_assets/node_modules/luxon/src/impl/zoneUtil.js10
-rw-r--r--npm_assets/node_modules/luxon/src/info.js58
-rw-r--r--npm_assets/node_modules/luxon/src/interval.js127
-rw-r--r--npm_assets/node_modules/luxon/src/luxon.js8
-rw-r--r--npm_assets/node_modules/luxon/src/luxonFilled.js13
-rw-r--r--npm_assets/node_modules/luxon/src/package.json4
-rw-r--r--npm_assets/node_modules/luxon/src/settings.js49
-rw-r--r--npm_assets/node_modules/luxon/src/zone.js7
-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
24 files changed, 1145 insertions, 969 deletions
diff --git a/npm_assets/node_modules/luxon/src/datetime.js b/npm_assets/node_modules/luxon/src/datetime.js
index 61ef8b4..5120b05 100644
--- a/npm_assets/node_modules/luxon/src/datetime.js
+++ b/npm_assets/node_modules/luxon/src/datetime.js
@@ -1,4 +1,4 @@
-import Duration, { friendlyDuration } from "./duration.js";
+import Duration from "./duration.js";
import Interval from "./interval.js";
import Settings from "./settings.js";
import Info from "./info.js";
@@ -17,12 +17,18 @@ import {
weeksInWeekYear,
normalizeObject,
roundTo,
- objToLocalTS
+ objToLocalTS,
+ padStart,
} from "./impl/util.js";
import { normalizeZone } from "./impl/zoneUtil.js";
import diff from "./impl/diff.js";
import { parseRFC2822Date, parseISODate, parseHTTPDate, parseSQL } from "./impl/regexParser.js";
-import { parseFromTokens, explainFromTokens } from "./impl/tokenParser.js";
+import {
+ parseFromTokens,
+ explainFromTokens,
+ formatOptsToTokens,
+ expandMacroTokens,
+} from "./impl/tokenParser.js";
import {
gregorianToWeek,
weekToGregorian,
@@ -31,14 +37,14 @@ import {
hasInvalidGregorianData,
hasInvalidWeekData,
hasInvalidOrdinalData,
- hasInvalidTimeData
+ hasInvalidTimeData,
} from "./impl/conversions.js";
import * as Formats from "./impl/formats.js";
import {
InvalidArgumentError,
ConflictingSpecificationError,
InvalidUnitError,
- InvalidDateTimeError
+ InvalidDateTimeError,
} from "./errors.js";
import Invalid from "./impl/invalid.js";
@@ -66,9 +72,9 @@ function clone(inst, alts) {
c: inst.c,
o: inst.o,
loc: inst.loc,
- invalid: inst.invalid
+ invalid: inst.invalid,
};
- return new DateTime(Object.assign({}, current, alts, { old: current }));
+ return new DateTime({ ...current, ...alts, old: current });
}
// find the right offset a given local time. The o input is our guess, which determines which
@@ -111,7 +117,7 @@ function tsToObj(ts, offset) {
hour: d.getUTCHours(),
minute: d.getUTCMinutes(),
second: d.getUTCSeconds(),
- millisecond: d.getUTCMilliseconds()
+ millisecond: d.getUTCMilliseconds(),
};
}
@@ -125,14 +131,15 @@ function adjustTime(inst, dur) {
const oPre = inst.o,
year = inst.c.year + Math.trunc(dur.years),
month = inst.c.month + Math.trunc(dur.months) + Math.trunc(dur.quarters) * 3,
- c = Object.assign({}, inst.c, {
+ c = {
+ ...inst.c,
year,
month,
day:
Math.min(inst.c.day, daysInMonth(year, month)) +
Math.trunc(dur.days) +
- Math.trunc(dur.weeks) * 7
- }),
+ Math.trunc(dur.weeks) * 7,
+ },
millisToAdd = Duration.fromObject({
years: dur.years - Math.trunc(dur.years),
quarters: dur.quarters - Math.trunc(dur.quarters),
@@ -142,7 +149,7 @@ function adjustTime(inst, dur) {
hours: dur.hours,
minutes: dur.minutes,
seconds: dur.seconds,
- milliseconds: dur.milliseconds
+ milliseconds: dur.milliseconds,
}).as("milliseconds"),
localTS = objToLocalTS(c);
@@ -159,17 +166,15 @@ function adjustTime(inst, dur) {
// helper useful in turning the results of parsing into real dates
// by handling the zone options
-function parseDataToDateTime(parsed, parsedZone, opts, format, text) {
+function parseDataToDateTime(parsed, parsedZone, opts, format, text, specificOffset) {
const { setZone, zone } = opts;
- if (parsed && Object.keys(parsed).length !== 0) {
+ if ((parsed && Object.keys(parsed).length !== 0) || parsedZone) {
const interpretationZone = parsedZone || zone,
- inst = DateTime.fromObject(
- Object.assign(parsed, opts, {
- zone: interpretationZone,
- // setZone is a valid option in the calling methods, but not in fromObject
- setZone: undefined
- })
- );
+ inst = DateTime.fromObject(parsed, {
+ ...opts,
+ zone: interpretationZone,
+ specificOffset,
+ });
return setZone ? inst : inst.setZone(zone);
} else {
return DateTime.invalid(
@@ -184,51 +189,77 @@ function toTechFormat(dt, format, allowZ = true) {
return dt.isValid
? Formatter.create(Locale.create("en-US"), {
allowZ,
- forceSimple: true
+ forceSimple: true,
}).formatDateTimeFromString(dt, format)
: null;
}
-// technical time formats (e.g. the time part of ISO 8601), take some options
-// and this commonizes their handling
-function toTechTimeFormat(
- dt,
- {
- suppressSeconds = false,
- suppressMilliseconds = false,
- includeOffset,
- includePrefix = false,
- includeZone = false,
- spaceZone = false,
- format = "extended"
+function toISODate(o, extended) {
+ const longFormat = o.c.year > 9999 || o.c.year < 0;
+ let c = "";
+ if (longFormat && o.c.year >= 0) c += "+";
+ c += padStart(o.c.year, longFormat ? 6 : 4);
+
+ if (extended) {
+ c += "-";
+ c += padStart(o.c.month);
+ c += "-";
+ c += padStart(o.c.day);
+ } else {
+ c += padStart(o.c.month);
+ c += padStart(o.c.day);
}
-) {
- let fmt = format === "basic" ? "HHmm" : "HH:mm";
+ return c;
+}
- if (!suppressSeconds || dt.second !== 0 || dt.millisecond !== 0) {
- fmt += format === "basic" ? "ss" : ":ss";
- if (!suppressMilliseconds || dt.millisecond !== 0) {
- fmt += ".SSS";
+function toISOTime(
+ o,
+ extended,
+ suppressSeconds,
+ suppressMilliseconds,
+ includeOffset,
+ extendedZone
+) {
+ let c = padStart(o.c.hour);
+ if (extended) {
+ c += ":";
+ c += padStart(o.c.minute);
+ if (o.c.second !== 0 || !suppressSeconds) {
+ c += ":";
}
+ } else {
+ c += padStart(o.c.minute);
}
- if ((includeZone || includeOffset) && spaceZone) {
- fmt += " ";
- }
+ if (o.c.second !== 0 || !suppressSeconds) {
+ c += padStart(o.c.second);
- if (includeZone) {
- fmt += "z";
- } else if (includeOffset) {
- fmt += format === "basic" ? "ZZZ" : "ZZ";
+ if (o.c.millisecond !== 0 || !suppressMilliseconds) {
+ c += ".";
+ c += padStart(o.c.millisecond, 3);
+ }
}
- let str = toTechFormat(dt, fmt);
-
- if (includePrefix) {
- str = "T" + str;
+ if (includeOffset) {
+ if (o.isOffsetFixed && o.offset === 0 && !extendedZone) {
+ c += "Z";
+ } else if (o.o < 0) {
+ c += "-";
+ c += padStart(Math.trunc(-o.o / 60));
+ c += ":";
+ c += padStart(Math.trunc(-o.o % 60));
+ } else {
+ c += "+";
+ c += padStart(Math.trunc(o.o / 60));
+ c += ":";
+ c += padStart(Math.trunc(o.o % 60));
+ }
}
- return str;
+ if (extendedZone) {
+ c += "[" + o.zone.ianaName + "]";
+ }
+ return c;
}
// defaults for unspecified units in the supported calendars
@@ -238,7 +269,7 @@ const defaultUnitValues = {
hour: 0,
minute: 0,
second: 0,
- millisecond: 0
+ millisecond: 0,
},
defaultWeekUnitValues = {
weekNumber: 1,
@@ -246,14 +277,14 @@ const defaultUnitValues = {
hour: 0,
minute: 0,
second: 0,
- millisecond: 0
+ millisecond: 0,
},
defaultOrdinalUnitValues = {
ordinal: 1,
hour: 0,
minute: 0,
second: 0,
- millisecond: 0
+ millisecond: 0,
};
// Units in the supported calendars, sorted by bigness
@@ -265,7 +296,7 @@ const orderedUnits = ["year", "month", "day", "hour", "minute", "second", "milli
"hour",
"minute",
"second",
- "millisecond"
+ "millisecond",
],
orderedOrdinalUnits = ["year", "ordinal", "hour", "minute", "second", "millisecond"];
@@ -295,7 +326,7 @@ function normalizeUnit(unit) {
weeknumbers: "weekNumber",
weekyear: "weekYear",
weekyears: "weekYear",
- ordinal: "ordinal"
+ ordinal: "ordinal",
}[unit.toLowerCase()];
if (!normalized) throw new InvalidUnitError(unit);
@@ -306,28 +337,33 @@ function normalizeUnit(unit) {
// this is a dumbed down version of fromObject() that runs about 60% faster
// but doesn't do any validation, makes a bunch of assumptions about what units
// are present, and so on.
-function quickDT(obj, zone) {
+function quickDT(obj, opts) {
+ const zone = normalizeZone(opts.zone, Settings.defaultZone),
+ loc = Locale.fromObject(opts),
+ tsNow = Settings.now();
+
+ let ts, o;
+
// assume we have the higher-order units
- for (const u of orderedUnits) {
- if (isUndefined(obj[u])) {
- obj[u] = defaultUnitValues[u];
+ if (!isUndefined(obj.year)) {
+ for (const u of orderedUnits) {
+ if (isUndefined(obj[u])) {
+ obj[u] = defaultUnitValues[u];
+ }
}
- }
- const invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
- if (invalid) {
- return DateTime.invalid(invalid);
- }
+ const invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
+ if (invalid) {
+ return DateTime.invalid(invalid);
+ }
- const tsNow = Settings.now(),
- offsetProvis = zone.offset(tsNow),
+ const offsetProvis = zone.offset(tsNow);
[ts, o] = objToTS(obj, offsetProvis, zone);
+ } else {
+ ts = tsNow;
+ }
- return new DateTime({
- ts,
- zone,
- o
- });
+ return new DateTime({ ts, zone, loc, o });
}
function diffRelative(start, end, opts) {
@@ -337,13 +373,10 @@ function diffRelative(start, end, opts) {
const formatter = end.loc.clone(opts).relFormatter(opts);
return formatter.format(c, unit);
},
- differ = unit => {
+ differ = (unit) => {
if (opts.calendary) {
if (!end.hasSame(start, unit)) {
- return end
- .startOf(unit)
- .diff(start.startOf(unit), unit)
- .get(unit);
+ return end.startOf(unit).diff(start.startOf(unit), unit).get(unit);
} else return 0;
} else {
return end.diff(start, unit).get(unit);
@@ -363,6 +396,18 @@ function diffRelative(start, end, opts) {
return format(start > end ? -0 : 0, opts.units[opts.units.length - 1]);
}
+function lastOpts(argList) {
+ let opts = {},
+ args;
+ if (argList.length > 0 && typeof argList[argList.length - 1] === "object") {
+ opts = argList[argList.length - 1];
+ args = Array.from(argList).slice(0, argList.length - 1);
+ } else {
+ args = Array.from(argList);
+ }
+ return [opts, args];
+}
+
/**
* A DateTime is an immutable data structure representing a specific date and time and accompanying methods. It contains class and instance methods for creating, parsing, interrogating, transforming, and formatting them.
*
@@ -373,13 +418,13 @@ function diffRelative(start, end, opts) {
*
* Here is a brief overview of the most commonly used functionality it provides:
*
- * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link local}, {@link utc}, and (most flexibly) {@link fromObject}. To create one from a standard string format, use {@link fromISO}, {@link fromHTTP}, and {@link fromRFC2822}. To create one from a custom string format, use {@link fromFormat}. To create one from a native JS date, use {@link fromJSDate}.
- * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link toObject}), use the {@link year}, {@link month},
- * {@link day}, {@link hour}, {@link minute}, {@link second}, {@link millisecond} accessors.
- * * **Week calendar**: For ISO week calendar attributes, see the {@link weekYear}, {@link weekNumber}, and {@link weekday} accessors.
- * * **Configuration** See the {@link locale} and {@link numberingSystem} accessors.
- * * **Transformation**: To transform the DateTime into other DateTimes, use {@link set}, {@link reconfigure}, {@link setZone}, {@link setLocale}, {@link plus}, {@link minus}, {@link endOf}, {@link startOf}, {@link toUTC}, and {@link toLocal}.
- * * **Output**: To convert the DateTime to other representations, use the {@link toRelative}, {@link toRelativeCalendar}, {@link toJSON}, {@link toISO}, {@link toHTTP}, {@link toObject}, {@link toRFC2822}, {@link toString}, {@link toLocaleString}, {@link toFormat}, {@link toMillis} and {@link toJSDate}.
+ * * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime.local}, {@link DateTime.utc}, and (most flexibly) {@link DateTime.fromObject}. To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}. To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}.
+ * * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year}, {@link DateTime#month},
+ * {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors.
+ * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors.
+ * * **Configuration** See the {@link DateTime#locale} and {@link DateTime#numberingSystem} accessors.
+ * * **Transformation**: To transform the DateTime into other DateTimes, use {@link DateTime#set}, {@link DateTime#reconfigure}, {@link DateTime#setZone}, {@link DateTime#setLocale}, {@link DateTime.plus}, {@link DateTime#minus}, {@link DateTime#endOf}, {@link DateTime#startOf}, {@link DateTime#toUTC}, and {@link DateTime#toLocal}.
+ * * **Output**: To convert the DateTime to other representations, use the {@link DateTime#toRelative}, {@link DateTime#toRelativeCalendar}, {@link DateTime#toJSON}, {@link DateTime#toISO}, {@link DateTime#toHTTP}, {@link DateTime#toObject}, {@link DateTime#toRFC2822}, {@link DateTime#toString}, {@link DateTime#toLocaleString}, {@link DateTime#toFormat}, {@link DateTime#toMillis} and {@link DateTime#toJSDate}.
*
* There's plenty others documented below. In addition, for more information on subtler topics like internationalization, time zones, alternative calendars, validity, and so on, see the external documentation.
*/
@@ -467,33 +512,22 @@ export default class DateTime {
* @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
* @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
* @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
- * @example DateTime.local() //~> now
- * @example DateTime.local(2017) //~> 2017-01-01T00:00:00
- * @example DateTime.local(2017, 3) //~> 2017-03-01T00:00:00
- * @example DateTime.local(2017, 3, 12) //~> 2017-03-12T00:00:00
- * @example DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00
- * @example DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00
- * @example DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10
- * @example DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765
+ * @example DateTime.local() //~> now
+ * @example DateTime.local({ zone: "America/New_York" }) //~> now, in US east coast time
+ * @example DateTime.local(2017) //~> 2017-01-01T00:00:00
+ * @example DateTime.local(2017, 3) //~> 2017-03-01T00:00:00
+ * @example DateTime.local(2017, 3, 12, { locale: "fr" }) //~> 2017-03-12T00:00:00, with a French locale
+ * @example DateTime.local(2017, 3, 12, 5) //~> 2017-03-12T05:00:00
+ * @example DateTime.local(2017, 3, 12, 5, { zone: "utc" }) //~> 2017-03-12T05:00:00, in UTC
+ * @example DateTime.local(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00
+ * @example DateTime.local(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10
+ * @example DateTime.local(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765
* @return {DateTime}
*/
- static local(year, month, day, hour, minute, second, millisecond) {
- if (isUndefined(year)) {
- return DateTime.now();
- } else {
- return quickDT(
- {
- year,
- month,
- day,
- hour,
- minute,
- second,
- millisecond
- },
- Settings.defaultZone
- );
- }
+ static local() {
+ const [opts, args] = lastOpts(arguments),
+ [year, month, day, hour, minute, second, millisecond] = args;
+ return quickDT({ year, month, day, hour, minute, second, millisecond }, opts);
}
/**
@@ -505,36 +539,27 @@ export default class DateTime {
* @param {number} [minute=0] - The minute of the hour, meaning a number between 0 and 59
* @param {number} [second=0] - The second of the minute, meaning a number between 0 and 59
* @param {number} [millisecond=0] - The millisecond of the second, meaning a number between 0 and 999
- * @example DateTime.utc() //~> now
- * @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
- * @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
- * @example DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z
- * @example DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z
- * @example DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z
- * @example DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z
- * @example DateTime.utc(2017, 3, 12, 5, 45, 10, 765) //~> 2017-03-12T05:45:10.765Z
+ * @param {Object} options - configuration options for the DateTime
+ * @param {string} [options.locale] - a locale to set on the resulting DateTime instance
+ * @param {string} [options.outputCalendar] - the output calendar to set on the resulting DateTime instance
+ * @param {string} [options.numberingSystem] - the numbering system to set on the resulting DateTime instance
+ * @example DateTime.utc() //~> now
+ * @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
+ * @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
+ * @example DateTime.utc(2017, 3, 12) //~> 2017-03-12T00:00:00Z
+ * @example DateTime.utc(2017, 3, 12, 5) //~> 2017-03-12T05:00:00Z
+ * @example DateTime.utc(2017, 3, 12, 5, 45) //~> 2017-03-12T05:45:00Z
+ * @example DateTime.utc(2017, 3, 12, 5, 45, { locale: "fr" }) //~> 2017-03-12T05:45:00Z with a French locale
+ * @example DateTime.utc(2017, 3, 12, 5, 45, 10) //~> 2017-03-12T05:45:10Z
+ * @example DateTime.utc(2017, 3, 12, 5, 45, 10, 765, { locale: "fr" }) //~> 2017-03-12T05:45:10.765Z with a French locale
* @return {DateTime}
*/
- static utc(year, month, day, hour, minute, second, millisecond) {
- if (isUndefined(year)) {
- return new DateTime({
- ts: Settings.now(),
- zone: FixedOffsetZone.utcInstance
- });
- } else {
- return quickDT(
- {
- year,
- month,
- day,
- hour,
- minute,
- second,
- millisecond
- },
- FixedOffsetZone.utcInstance
- );
- }
+ static utc() {
+ const [opts, args] = lastOpts(arguments),
+ [year, month, day, hour, minute, second, millisecond] = args;
+
+ opts.zone = FixedOffsetZone.utcInstance;
+ return quickDT({ year, month, day, hour, minute, second, millisecond }, opts);
}
/**
@@ -558,7 +583,7 @@ export default class DateTime {
return new DateTime({
ts: ts,
zone: zoneToUse,
- loc: Locale.fromObject(options)
+ loc: Locale.fromObject(options),
});
}
@@ -584,7 +609,7 @@ export default class DateTime {
return new DateTime({
ts: milliseconds,
zone: normalizeZone(options.zone, Settings.defaultZone),
- loc: Locale.fromObject(options)
+ loc: Locale.fromObject(options),
});
}
}
@@ -606,7 +631,7 @@ export default class DateTime {
return new DateTime({
ts: seconds * 1000,
zone: normalizeZone(options.zone, Settings.defaultZone),
- loc: Locale.fromObject(options)
+ loc: Locale.fromObject(options),
});
}
}
@@ -625,39 +650,38 @@ export default class DateTime {
* @param {number} obj.minute - minute of the hour, 0-59
* @param {number} obj.second - second of the minute, 0-59
* @param {number} obj.millisecond - millisecond of the second, 0-999
- * @param {string|Zone} [obj.zone='local'] - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone()
- * @param {string} [obj.locale='system's locale'] - a locale to set on the resulting DateTime instance
- * @param {string} obj.outputCalendar - the output calendar to set on the resulting DateTime instance
- * @param {string} obj.numberingSystem - the numbering system to set on the resulting DateTime instance
+ * @param {Object} opts - options for creating this DateTime
+ * @param {string|Zone} [opts.zone='local'] - interpret the numbers in the context of a particular zone. Can take any value taken as the first argument to setZone()
+ * @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
+ * @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
+ * @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
* @example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'
* @example DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'
* @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06
- * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'utc' }),
- * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'local' })
- * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6, zone: 'America/New_York' })
+ * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'utc' }),
+ * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'local' })
+ * @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }, { zone: 'America/New_York' })
* @example DateTime.fromObject({ weekYear: 2016, weekNumber: 2, weekday: 3 }).toISODate() //=> '2016-01-13'
* @return {DateTime}
*/
- static fromObject(obj) {
- const zoneToUse = normalizeZone(obj.zone, Settings.defaultZone);
+ static fromObject(obj, opts = {}) {
+ obj = obj || {};
+ const zoneToUse = normalizeZone(opts.zone, Settings.defaultZone);
if (!zoneToUse.isValid) {
return DateTime.invalid(unsupportedZone(zoneToUse));
}
const tsNow = Settings.now(),
- offsetProvis = zoneToUse.offset(tsNow),
- normalized = normalizeObject(obj, normalizeUnit, [
- "zone",
- "locale",
- "outputCalendar",
- "numberingSystem"
- ]),
+ offsetProvis = !isUndefined(opts.specificOffset)
+ ? opts.specificOffset
+ : zoneToUse.offset(tsNow),
+ normalized = normalizeObject(obj, normalizeUnit),
containsOrdinal = !isUndefined(normalized.ordinal),
containsGregorYear = !isUndefined(normalized.year),
containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day),
containsGregor = containsGregorYear || containsGregorMD,
definiteWeekDef = normalized.weekYear || normalized.weekNumber,
- loc = Locale.fromObject(obj);
+ loc = Locale.fromObject(opts);
// cases:
// just a weekday -> this week's instance of that weekday, no worries
@@ -711,8 +735,8 @@ export default class DateTime {
const higherOrderInvalid = useWeekData
? hasInvalidWeekData(normalized)
: containsOrdinal
- ? hasInvalidOrdinalData(normalized)
- : hasInvalidGregorianData(normalized),
+ ? hasInvalidOrdinalData(normalized)
+ : hasInvalidGregorianData(normalized),
invalid = higherOrderInvalid || hasInvalidTimeData(normalized);
if (invalid) {
@@ -723,14 +747,14 @@ export default class DateTime {
const gregorian = useWeekData
? weekToGregorian(normalized)
: containsOrdinal
- ? ordinalToGregorian(normalized)
- : normalized,
+ ? ordinalToGregorian(normalized)
+ : normalized,
[tsFinal, offsetFinal] = objToTS(gregorian, offsetProvis, zoneToUse),
inst = new DateTime({
ts: tsFinal,
zone: zoneToUse,
o: offsetFinal,
- loc
+ loc,
});
// gregorian data + weekday serves only to validate
@@ -806,8 +830,7 @@ export default class DateTime {
/**
* Create a DateTime from an input string and format string.
- * Defaults to en-US if no locale has been specified, regardless of the system's locale.
- * @see https://moment.github.io/luxon/docs/manual/parsing.html#table-of-tokens
+ * Defaults to en-US if no locale has been specified, regardless of the system's locale. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/parsing?id=table-of-tokens).
* @param {string} text - the string to parse
* @param {string} fmt - the format the string is expected to be in (see the link below for the formats)
* @param {Object} opts - options to affect the creation
@@ -827,13 +850,13 @@ export default class DateTime {
localeToUse = Locale.fromOpts({
locale,
numberingSystem,
- defaultToEN: true
+ defaultToEN: true,
}),
- [vals, parsedZone, invalid] = parseFromTokens(localeToUse, text, fmt);
+ [vals, parsedZone, specificOffset, invalid] = parseFromTokens(localeToUse, text, fmt);
if (invalid) {
return DateTime.invalid(invalid);
} else {
- return parseDataToDateTime(vals, parsedZone, opts, `format ${fmt}`, text);
+ return parseDataToDateTime(vals, parsedZone, opts, `format ${fmt}`, text, specificOffset);
}
}
@@ -871,7 +894,7 @@ export default class DateTime {
/**
* Create an invalid DateTime.
- * @param {string} reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent
+ * @param {DateTime} reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent
* @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
* @return {DateTime}
*/
@@ -890,7 +913,7 @@ export default class DateTime {
}
/**
- * Check if an object is a DateTime. Works across context boundaries
+ * Check if an object is an instance of DateTime. Works across context boundaries
* @param {object} o
* @return {boolean}
*/
@@ -898,6 +921,29 @@ export default class DateTime {
return (o && o.isLuxonDateTime) || false;
}
+ /**
+ * Produce the format string for a set of options
+ * @param formatOpts
+ * @param localeOpts
+ * @returns {string}
+ */
+ static parseFormatForOpts(formatOpts, localeOpts = {}) {
+ const tokenList = formatOptsToTokens(formatOpts, Locale.fromObject(localeOpts));
+ return !tokenList ? null : tokenList.map((t) => (t ? t.val : null)).join("");
+ }
+
+ /**
+ * Produce the the fully expanded format token for the locale
+ * Does NOT quote characters, so quoted tokens will not round trip correctly
+ * @param fmt
+ * @param localeOpts
+ * @returns {string}
+ */
+ static expandFormat(fmt, localeOpts = {}) {
+ const expanded = expandMacroTokens(Formatter.parseFormat(fmt), Locale.fromObject(localeOpts));
+ return expanded.map((t) => t.val).join("");
+ }
+
// INFO
/**
@@ -1151,7 +1197,7 @@ export default class DateTime {
if (this.isValid) {
return this.zone.offsetName(this.ts, {
format: "short",
- locale: this.locale
+ locale: this.locale,
});
} else {
return null;
@@ -1167,7 +1213,7 @@ export default class DateTime {
if (this.isValid) {
return this.zone.offsetName(this.ts, {
format: "long",
- locale: this.locale
+ locale: this.locale,
});
} else {
return null;
@@ -1179,7 +1225,7 @@ export default class DateTime {
* @type {boolean}
*/
get isOffsetFixed() {
- return this.isValid ? this.zone.universal : null;
+ return this.isValid ? this.zone.isUniversal : null;
}
/**
@@ -1191,7 +1237,8 @@ export default class DateTime {
return false;
} else {
return (
- this.offset > this.set({ month: 1 }).offset || this.offset > this.set({ month: 5 }).offset
+ this.offset > this.set({ month: 1, day: 1 }).offset ||
+ this.offset > this.set({ month: 5 }).offset
);
}
}
@@ -1243,7 +1290,7 @@ export default class DateTime {
* @param {Object} opts - the same options as toLocaleString
* @return {Object}
*/
- resolvedLocaleOpts(opts = {}) {
+ resolvedLocaleOptions(opts = {}) {
const { locale, numberingSystem, calendar } = Formatter.create(
this.loc.clone(opts),
opts
@@ -1256,7 +1303,7 @@ export default class DateTime {
/**
* "Set" the DateTime's zone to UTC. Returns a newly-constructed DateTime.
*
- * Equivalent to {@link setZone}('utc')
+ * Equivalent to {@link DateTime#setZone}('utc')
* @param {number} [offset=0] - optionally, an offset from UTC in minutes
* @param {Object} [opts={}] - options to pass to `setZone()`
* @return {DateTime}
@@ -1278,8 +1325,8 @@ export default class DateTime {
/**
* "Set" the DateTime's zone to specified zone. Returns a newly-constructed DateTime.
*
- * By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, as with {@link plus}. You may wish to use {@link toLocal} and {@link toUTC} which provide simple convenience wrappers for commonly used zones.
- * @param {string|Zone} [zone='local'] - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. You may also supply an instance of a {@link Zone} class.
+ * By default, the setter keeps the underlying time the same (as in, the same timestamp), but the new instance will report different local times and consider DSTs when making computations, as with {@link DateTime#plus}. You may wish to use {@link DateTime#toLocal} and {@link DateTime#toUTC} which provide simple convenience wrappers for commonly used zones.
+ * @param {string|Zone} [zone='local'] - a zone identifier. As a string, that can be any IANA zone supported by the host environment, or a fixed-offset name of the form 'UTC+3', or the strings 'local' or 'utc'. You may also supply an instance of a {@link DateTime#Zone} class.
* @param {Object} opts - options
* @param {boolean} [opts.keepLocalTime=false] - If true, adjust the underlying time so that the local time stays the same, but in the target zone. You should rarely need this.
* @return {DateTime}
@@ -1324,7 +1371,7 @@ export default class DateTime {
/**
* "Set" the values of specified units. Returns a newly-constructed DateTime.
- * You can only set units with this method; for "setting" metadata, see {@link reconfigure} and {@link setZone}.
+ * You can only set units with this method; for "setting" metadata, see {@link DateTime#reconfigure} and {@link DateTime#setZone}.
* @param {Object} values - a mapping of units to numbers
* @example dt.set({ year: 2017 })
* @example dt.set({ hour: 8, minute: 30 })
@@ -1335,7 +1382,7 @@ export default class DateTime {
set(values) {
if (!this.isValid) return this;
- const normalized = normalizeObject(values, normalizeUnit, []),
+ const normalized = normalizeObject(values, normalizeUnit),
settingWeekStuff =
!isUndefined(normalized.weekYear) ||
!isUndefined(normalized.weekNumber) ||
@@ -1358,11 +1405,11 @@ export default class DateTime {
let mixed;
if (settingWeekStuff) {
- mixed = weekToGregorian(Object.assign(gregorianToWeek(this.c), normalized));
+ mixed = weekToGregorian({ ...gregorianToWeek(this.c), ...normalized });
} else if (!isUndefined(normalized.ordinal)) {
- mixed = ordinalToGregorian(Object.assign(gregorianToOrdinal(this.c), normalized));
+ mixed = ordinalToGregorian({ ...gregorianToOrdinal(this.c), ...normalized });
} else {
- mixed = Object.assign(this.toObject(), normalized);
+ mixed = { ...this.toObject(), ...normalized };
// if we didn't set the day but we ended up on an overflow date,
// use the last day of the right month
@@ -1390,19 +1437,19 @@ export default class DateTime {
*/
plus(duration) {
if (!this.isValid) return this;
- const dur = friendlyDuration(duration);
+ const dur = Duration.fromDurationLike(duration);
return clone(this, adjustTime(this, dur));
}
/**
* Subtract a period of time to this DateTime and return the resulting DateTime
- * See {@link plus}
+ * See {@link DateTime#plus}
* @param {Duration|Object|number} duration - The amount to subtract. Either a Luxon Duration, a number of milliseconds, the object argument to Duration.fromObject()
@return {DateTime}
- */
+ */
minus(duration) {
if (!this.isValid) return this;
- const dur = friendlyDuration(duration).negate();
+ const dur = Duration.fromDurationLike(duration).negate();
return clone(this, adjustTime(this, dur));
}
@@ -1480,11 +1527,10 @@ export default class DateTime {
/**
* Returns a string representation of this DateTime formatted according to the specified format string.
- * **You may not want this.** See {@link toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens).
+ * **You may not want this.** See {@link DateTime#toLocaleString} for a more flexible formatting tool. For a table of tokens and their interpretations, see [here](https://moment.github.io/luxon/#/formatting?id=table-of-tokens).
* Defaults to en-US if no locale has been specified, regardless of the system's locale.
- * @see https://moment.github.io/luxon/docs/manual/formatting.html#table-of-tokens
* @param {string} fmt - the format string
- * @param {Object} opts - opts to override the configuration options
+ * @param {Object} opts - opts to override the configuration options on this DateTime
* @example DateTime.now().toFormat('yyyy LLL dd') //=> '2017 Apr 22'
* @example DateTime.now().setLocale('fr').toFormat('yyyy LLL dd') //=> '2017 avr. 22'
* @example DateTime.now().toFormat('yyyy LLL dd', { locale: "fr" }) //=> '2017 avr. 22'
@@ -1503,21 +1549,22 @@ export default class DateTime {
* of the DateTime in the assigned locale.
* Defaults to the system's locale if no locale has been specified
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
- * @param opts {Object} - Intl.DateTimeFormat constructor options and configuration options
+ * @param formatOpts {Object} - Intl.DateTimeFormat constructor options and configuration options
+ * @param {Object} opts - opts to override the configuration options on this DateTime
* @example DateTime.now().toLocaleString(); //=> 4/20/2017
* @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
- * @example DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
* @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
+ * @example DateTime.now().toLocaleString(DateTime.DATE_FULL, { locale: 'fr' }); //=> '28 août 2022'
* @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
* @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
* @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
* @example DateTime.now().toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> 'Thu, Apr 20, 11:27 AM'
- * @example DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hour12: false }); //=> '11:32'
+ * @example DateTime.now().toLocaleString({ hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }); //=> '11:32'
* @return {string}
*/
- toLocaleString(opts = Formats.DATE_SHORT) {
+ toLocaleString(formatOpts = Formats.DATE_SHORT, opts = {}) {
return this.isValid
- ? Formatter.create(this.loc.clone(opts), opts).formatDateTime(this)
+ ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this)
: INVALID;
}
@@ -1546,19 +1593,31 @@ export default class DateTime {
* @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
* @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
+ * @param {boolean} [opts.extendedZone=false] - add the time zone format extension
* @param {string} [opts.format='extended'] - choose between the basic and extended format
- * @example DateTime.utc(1982, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
+ * @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
* @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
* @example DateTime.now().toISO({ includeOffset: false }) //=> '2017-04-22T20:47:05.335'
* @example DateTime.now().toISO({ format: 'basic' }) //=> '20170422T204705.335-0400'
* @return {string}
*/
- toISO(opts = {}) {
+ toISO({
+ format = "extended",
+ suppressSeconds = false,
+ suppressMilliseconds = false,
+ includeOffset = true,
+ extendedZone = false,
+ } = {}) {
if (!this.isValid) {
return null;
}
- return `${this.toISODate(opts)}T${this.toISOTime(opts)}`;
+ const ext = format === "extended";
+
+ let c = toISODate(this, ext);
+ c += "T";
+ c += toISOTime(this, ext, suppressSeconds, suppressMilliseconds, includeOffset, extendedZone);
+ return c;
}
/**
@@ -1570,12 +1629,11 @@ export default class DateTime {
* @return {string}
*/
toISODate({ format = "extended" } = {}) {
- let fmt = format === "basic" ? "yyyyMMdd" : "yyyy-MM-dd";
- if (this.year > 9999) {
- fmt = "+" + fmt;
+ if (!this.isValid) {
+ return null;
}
- return toTechFormat(this, fmt);
+ return toISODate(this, format === "extended");
}
/**
@@ -1593,6 +1651,7 @@ export default class DateTime {
* @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
* @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
+ * @param {boolean} [opts.extendedZone=true] - add the time zone format extension
* @param {boolean} [opts.includePrefix=false] - include the `T` prefix
* @param {string} [opts.format='extended'] - choose between the basic and extended format
* @example DateTime.utc().set({ hour: 7, minute: 34 }).toISOTime() //=> '07:34:19.361Z'
@@ -1606,19 +1665,29 @@ export default class DateTime {
suppressSeconds = false,
includeOffset = true,
includePrefix = false,
- format = "extended"
+ extendedZone = false,
+ format = "extended",
} = {}) {
- return toTechTimeFormat(this, {
- suppressSeconds,
- suppressMilliseconds,
- includeOffset,
- includePrefix,
- format
- });
+ if (!this.isValid) {
+ return null;
+ }
+
+ let c = includePrefix ? "T" : "";
+ return (
+ c +
+ toISOTime(
+ this,
+ format === "extended",
+ suppressSeconds,
+ suppressMilliseconds,
+ includeOffset,
+ extendedZone
+ )
+ );
}
/**
- * Returns an RFC 2822-compatible string representation of this DateTime, always in UTC
+ * Returns an RFC 2822-compatible string representation of this DateTime
* @example DateTime.utc(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 +0000'
* @example DateTime.local(2014, 7, 13).toRFC2822() //=> 'Sun, 13 Jul 2014 00:00:00 -0400'
* @return {string}
@@ -1628,7 +1697,7 @@ export default class DateTime {
}
/**
- * Returns a string representation of this DateTime appropriate for use in HTTP headers.
+ * Returns a string representation of this DateTime appropriate for use in HTTP headers. The output is always expressed in GMT.
* Specifically, the string conforms to RFC 1123.
* @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1
* @example DateTime.utc(2014, 7, 13).toHTTP() //=> 'Sun, 13 Jul 2014 00:00:00 GMT'
@@ -1645,7 +1714,10 @@ export default class DateTime {
* @return {string}
*/
toSQLDate() {
- return toTechFormat(this, "yyyy-MM-dd");
+ if (!this.isValid) {
+ return null;
+ }
+ return toISODate(this, true);
}
/**
@@ -1653,18 +1725,28 @@ export default class DateTime {
* @param {Object} opts - options
* @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
+ * @param {boolean} [opts.includeOffsetSpace=true] - include the space between the time and the offset, such as '05:15:16.345 -04:00'
* @example DateTime.utc().toSQL() //=> '05:15:16.345'
* @example DateTime.now().toSQL() //=> '05:15:16.345 -04:00'
* @example DateTime.now().toSQL({ includeOffset: false }) //=> '05:15:16.345'
* @example DateTime.now().toSQL({ includeZone: false }) //=> '05:15:16.345 America/New_York'
* @return {string}
*/
- toSQLTime({ includeOffset = true, includeZone = false } = {}) {
- return toTechTimeFormat(this, {
- includeOffset,
- includeZone,
- spaceZone: true
- });
+ toSQLTime({ includeOffset = true, includeZone = false, includeOffsetSpace = true } = {}) {
+ let fmt = "HH:mm:ss.SSS";
+
+ if (includeZone || includeOffset) {
+ if (includeOffsetSpace) {
+ fmt += " ";
+ }
+ if (includeZone) {
+ fmt += "z";
+ } else if (includeOffset) {
+ fmt += "ZZ";
+ }
+ }
+
+ return toTechFormat(this, fmt, true);
}
/**
@@ -1672,6 +1754,7 @@ export default class DateTime {
* @param {Object} opts - options
* @param {boolean} [opts.includeZone=false] - include the zone, such as 'America/New_York'. Overrides includeOffset.
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
+ * @param {boolean} [opts.includeOffsetSpace=true] - include the space between the time and the offset, such as '05:15:16.345 -04:00'
* @example DateTime.utc(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 Z'
* @example DateTime.local(2014, 7, 13).toSQL() //=> '2014-07-13 00:00:00.000 -04:00'
* @example DateTime.local(2014, 7, 13).toSQL({ includeOffset: false }) //=> '2014-07-13 00:00:00.000'
@@ -1695,7 +1778,7 @@ export default class DateTime {
}
/**
- * Returns the epoch milliseconds of this DateTime. Alias of {@link toMillis}
+ * Returns the epoch milliseconds of this DateTime. Alias of {@link DateTime#toMillis}
* @return {number}
*/
valueOf() {
@@ -1719,6 +1802,14 @@ export default class DateTime {
}
/**
+ * Returns the epoch seconds (as a whole number) of this DateTime.
+ * @return {number}
+ */
+ toUnixInteger() {
+ return this.isValid ? Math.floor(this.ts / 1000) : NaN;
+ }
+
+ /**
* Returns an ISO 8601 representation of this DateTime appropriate for use in JSON.
* @return {string}
*/
@@ -1744,7 +1835,7 @@ export default class DateTime {
toObject(opts = {}) {
if (!this.isValid) return {};
- const base = Object.assign({}, this.c);
+ const base = { ...this.c };
if (opts.includeConfig) {
base.outputCalendar = this.outputCalendar;
@@ -1781,16 +1872,10 @@ export default class DateTime {
*/
diff(otherDateTime, unit = "milliseconds", opts = {}) {
if (!this.isValid || !otherDateTime.isValid) {
- return Duration.invalid(
- this.invalid || otherDateTime.invalid,
- "created by diffing an invalid DateTime"
- );
+ return Duration.invalid("created by diffing an invalid DateTime");
}
- const durOpts = Object.assign(
- { locale: this.locale, numberingSystem: this.numberingSystem },
- opts
- );
+ const durOpts = { locale: this.locale, numberingSystem: this.numberingSystem, ...opts };
const units = maybeArray(unit).map(Duration.normalizeUnit),
otherIsLater = otherDateTime.valueOf() > this.valueOf(),
@@ -1803,7 +1888,7 @@ export default class DateTime {
/**
* Return the difference between this DateTime and right now.
- * See {@link diff}
+ * See {@link DateTime#diff}
* @param {string|string[]} [unit=['milliseconds']] - the unit or units units (such as 'hours' or 'days') to include in the duration
* @param {Object} opts - options that affect the creation of the Duration
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
@@ -1825,7 +1910,7 @@ export default class DateTime {
/**
* Return whether this DateTime is in the same unit of time as another DateTime.
* Higher-order units must also be identical for this function to return `true`.
- * Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link setZone} to convert one of the dates if needed.
+ * Note that time zones are **ignored** in this comparison, which compares the **local** calendar time. Use {@link DateTime#setZone} to convert one of the dates if needed.
* @param {DateTime} otherDateTime - the other DateTime
* @param {string} unit - the unit of time to check sameness on
* @example DateTime.now().hasSame(otherDT, 'day'); //~> true if otherDT is in the same current calendar day
@@ -1835,13 +1920,13 @@ export default class DateTime {
if (!this.isValid) return false;
const inputMs = otherDateTime.valueOf();
- const otherZoneDateTime = this.setZone(otherDateTime.zone, { keepLocalTime: true });
- return otherZoneDateTime.startOf(unit) <= inputMs && inputMs <= otherZoneDateTime.endOf(unit);
+ const adjustedToZone = this.setZone(otherDateTime.zone, { keepLocalTime: true });
+ return adjustedToZone.startOf(unit) <= inputMs && inputMs <= adjustedToZone.endOf(unit);
}
/**
* Equality check
- * Two DateTimes are equal iff they represent the same millisecond, have the same zone and location, and are both valid.
+ * Two DateTimes are equal if and only if they represent the same millisecond, have the same zone and location, and are both valid.
* To compare just the millisecond values, use `+dt1 === +dt2`.
* @param {DateTime} other - the other DateTime
* @return {boolean}
@@ -1876,7 +1961,7 @@ export default class DateTime {
*/
toRelative(options = {}) {
if (!this.isValid) return null;
- const base = options.base || DateTime.fromObject({ zone: this.zone }),
+ const base = options.base || DateTime.fromObject({}, { zone: this.zone }),
padding = options.padding ? (this < base ? -options.padding : options.padding) : 0;
let units = ["years", "months", "days", "hours", "minutes", "seconds"];
let unit = options.unit;
@@ -1884,15 +1969,12 @@ export default class DateTime {
units = options.unit;
unit = undefined;
}
- return diffRelative(
- base,
- this.plus(padding),
- Object.assign(options, {
- numeric: "always",
- units,
- unit
- })
- );
+ return diffRelative(base, this.plus(padding), {
+ ...options,
+ numeric: "always",
+ units,
+ unit,
+ });
}
/**
@@ -1911,15 +1993,12 @@ export default class DateTime {
toRelativeCalendar(options = {}) {
if (!this.isValid) return null;
- return diffRelative(
- options.base || DateTime.fromObject({ zone: this.zone }),
- this,
- Object.assign(options, {
- numeric: "auto",
- units: ["years", "months", "days"],
- calendary: true
- })
- );
+ return diffRelative(options.base || DateTime.fromObject({}, { zone: this.zone }), this, {
+ ...options,
+ numeric: "auto",
+ units: ["years", "months", "days"],
+ calendary: true,
+ });
}
/**
@@ -1931,7 +2010,7 @@ export default class DateTime {
if (!dateTimes.every(DateTime.isDateTime)) {
throw new InvalidArgumentError("min requires all arguments be DateTimes");
}
- return bestBy(dateTimes, i => i.valueOf(), Math.min);
+ return bestBy(dateTimes, (i) => i.valueOf(), Math.min);
}
/**
@@ -1943,7 +2022,7 @@ export default class DateTime {
if (!dateTimes.every(DateTime.isDateTime)) {
throw new InvalidArgumentError("max requires all arguments be DateTimes");
}
- return bestBy(dateTimes, i => i.valueOf(), Math.max);
+ return bestBy(dateTimes, (i) => i.valueOf(), Math.max);
}
// MISC
@@ -1960,7 +2039,7 @@ export default class DateTime {
localeToUse = Locale.fromOpts({
locale,
numberingSystem,
- defaultToEN: true
+ defaultToEN: true,
});
return explainFromTokens(localeToUse, text, fmt);
}
@@ -1975,7 +2054,7 @@ export default class DateTime {
// FORMAT PRESETS
/**
- * {@link toLocaleString} format like 10/14/1983
+ * {@link DateTime#toLocaleString} format like 10/14/1983
* @type {Object}
*/
static get DATE_SHORT() {
@@ -1983,7 +2062,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'Oct 14, 1983'
+ * {@link DateTime#toLocaleString} format like 'Oct 14, 1983'
* @type {Object}
*/
static get DATE_MED() {
@@ -1991,7 +2070,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'Fri, Oct 14, 1983'
+ * {@link DateTime#toLocaleString} format like 'Fri, Oct 14, 1983'
* @type {Object}
*/
static get DATE_MED_WITH_WEEKDAY() {
@@ -1999,7 +2078,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'October 14, 1983'
+ * {@link DateTime#toLocaleString} format like 'October 14, 1983'
* @type {Object}
*/
static get DATE_FULL() {
@@ -2007,7 +2086,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'Tuesday, October 14, 1983'
+ * {@link DateTime#toLocaleString} format like 'Tuesday, October 14, 1983'
* @type {Object}
*/
static get DATE_HUGE() {
@@ -2015,7 +2094,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like '09:30 AM'. Only 12-hour if the locale is.
* @type {Object}
*/
static get TIME_SIMPLE() {
@@ -2023,7 +2102,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like '09:30:23 AM'. Only 12-hour if the locale is.
* @type {Object}
*/
static get TIME_WITH_SECONDS() {
@@ -2031,7 +2110,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like '09:30:23 AM EDT'. Only 12-hour if the locale is.
* @type {Object}
*/
static get TIME_WITH_SHORT_OFFSET() {
@@ -2039,7 +2118,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like '09:30:23 AM Eastern Daylight Time'. Only 12-hour if the locale is.
* @type {Object}
*/
static get TIME_WITH_LONG_OFFSET() {
@@ -2047,7 +2126,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '09:30', always 24-hour.
+ * {@link DateTime#toLocaleString} format like '09:30', always 24-hour.
* @type {Object}
*/
static get TIME_24_SIMPLE() {
@@ -2055,7 +2134,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '09:30:23', always 24-hour.
+ * {@link DateTime#toLocaleString} format like '09:30:23', always 24-hour.
* @type {Object}
*/
static get TIME_24_WITH_SECONDS() {
@@ -2063,7 +2142,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '09:30:23 EDT', always 24-hour.
+ * {@link DateTime#toLocaleString} format like '09:30:23 EDT', always 24-hour.
* @type {Object}
*/
static get TIME_24_WITH_SHORT_OFFSET() {
@@ -2071,7 +2150,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
+ * {@link DateTime#toLocaleString} format like '09:30:23 Eastern Daylight Time', always 24-hour.
* @type {Object}
*/
static get TIME_24_WITH_LONG_OFFSET() {
@@ -2079,7 +2158,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_SHORT() {
@@ -2087,7 +2166,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_SHORT_WITH_SECONDS() {
@@ -2095,7 +2174,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like 'Oct 14, 1983, 9:30 AM'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_MED() {
@@ -2103,7 +2182,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like 'Oct 14, 1983, 9:30:33 AM'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_MED_WITH_SECONDS() {
@@ -2111,7 +2190,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like 'Fri, 14 Oct 1983, 9:30 AM'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_MED_WITH_WEEKDAY() {
@@ -2119,7 +2198,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like 'October 14, 1983, 9:30 AM EDT'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_FULL() {
@@ -2127,7 +2206,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like 'October 14, 1983, 9:30:33 AM EDT'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_FULL_WITH_SECONDS() {
@@ -2135,7 +2214,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like 'Friday, October 14, 1983, 9:30 AM Eastern Daylight Time'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_HUGE() {
@@ -2143,7 +2222,7 @@ export default class DateTime {
}
/**
- * {@link toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
+ * {@link DateTime#toLocaleString} format like 'Friday, October 14, 1983, 9:30:33 AM Eastern Daylight Time'. Only 12-hour if the locale is.
* @type {Object}
*/
static get DATETIME_HUGE_WITH_SECONDS() {
diff --git a/npm_assets/node_modules/luxon/src/duration.js b/npm_assets/node_modules/luxon/src/duration.js
index 4fcfa4b..fc512b6 100644
--- a/npm_assets/node_modules/luxon/src/duration.js
+++ b/npm_assets/node_modules/luxon/src/duration.js
@@ -9,97 +9,94 @@ import {
isNumber,
isUndefined,
normalizeObject,
- roundTo
+ roundTo,
} from "./impl/util.js";
import Settings from "./settings.js";
const INVALID = "Invalid Duration";
// unit conversion constants
-const lowOrderMatrix = {
+export const lowOrderMatrix = {
weeks: {
days: 7,
hours: 7 * 24,
minutes: 7 * 24 * 60,
seconds: 7 * 24 * 60 * 60,
- milliseconds: 7 * 24 * 60 * 60 * 1000
+ milliseconds: 7 * 24 * 60 * 60 * 1000,
},
days: {
hours: 24,
minutes: 24 * 60,
seconds: 24 * 60 * 60,
- milliseconds: 24 * 60 * 60 * 1000
+ milliseconds: 24 * 60 * 60 * 1000,
},
hours: { minutes: 60, seconds: 60 * 60, milliseconds: 60 * 60 * 1000 },
minutes: { seconds: 60, milliseconds: 60 * 1000 },
- seconds: { milliseconds: 1000 }
+ seconds: { milliseconds: 1000 },
},
- casualMatrix = Object.assign(
- {
- years: {
- quarters: 4,
- months: 12,
- weeks: 52,
- days: 365,
- hours: 365 * 24,
- minutes: 365 * 24 * 60,
- seconds: 365 * 24 * 60 * 60,
- milliseconds: 365 * 24 * 60 * 60 * 1000
- },
- quarters: {
- months: 3,
- weeks: 13,
- days: 91,
- hours: 91 * 24,
- minutes: 91 * 24 * 60,
- seconds: 91 * 24 * 60 * 60,
- milliseconds: 91 * 24 * 60 * 60 * 1000
- },
- months: {
- weeks: 4,
- days: 30,
- hours: 30 * 24,
- minutes: 30 * 24 * 60,
- seconds: 30 * 24 * 60 * 60,
- milliseconds: 30 * 24 * 60 * 60 * 1000
- }
+ casualMatrix = {
+ years: {
+ quarters: 4,
+ months: 12,
+ weeks: 52,
+ days: 365,
+ hours: 365 * 24,
+ minutes: 365 * 24 * 60,
+ seconds: 365 * 24 * 60 * 60,
+ milliseconds: 365 * 24 * 60 * 60 * 1000,
+ },
+ quarters: {
+ months: 3,
+ weeks: 13,
+ days: 91,
+ hours: 91 * 24,
+ minutes: 91 * 24 * 60,
+ seconds: 91 * 24 * 60 * 60,
+ milliseconds: 91 * 24 * 60 * 60 * 1000,
},
- lowOrderMatrix
- ),
+ months: {
+ weeks: 4,
+ days: 30,
+ hours: 30 * 24,
+ minutes: 30 * 24 * 60,
+ seconds: 30 * 24 * 60 * 60,
+ milliseconds: 30 * 24 * 60 * 60 * 1000,
+ },
+
+ ...lowOrderMatrix,
+ },
daysInYearAccurate = 146097.0 / 400,
daysInMonthAccurate = 146097.0 / 4800,
- accurateMatrix = Object.assign(
- {
- years: {
- quarters: 4,
- months: 12,
- weeks: daysInYearAccurate / 7,
- days: daysInYearAccurate,
- hours: daysInYearAccurate * 24,
- minutes: daysInYearAccurate * 24 * 60,
- seconds: daysInYearAccurate * 24 * 60 * 60,
- milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000
- },
- quarters: {
- months: 3,
- weeks: daysInYearAccurate / 28,
- days: daysInYearAccurate / 4,
- hours: (daysInYearAccurate * 24) / 4,
- minutes: (daysInYearAccurate * 24 * 60) / 4,
- seconds: (daysInYearAccurate * 24 * 60 * 60) / 4,
- milliseconds: (daysInYearAccurate * 24 * 60 * 60 * 1000) / 4
- },
- months: {
- weeks: daysInMonthAccurate / 7,
- days: daysInMonthAccurate,
- hours: daysInMonthAccurate * 24,
- minutes: daysInMonthAccurate * 24 * 60,
- seconds: daysInMonthAccurate * 24 * 60 * 60,
- milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1000
- }
+ accurateMatrix = {
+ years: {
+ quarters: 4,
+ months: 12,
+ weeks: daysInYearAccurate / 7,
+ days: daysInYearAccurate,
+ hours: daysInYearAccurate * 24,
+ minutes: daysInYearAccurate * 24 * 60,
+ seconds: daysInYearAccurate * 24 * 60 * 60,
+ milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1000,
+ },
+ quarters: {
+ months: 3,
+ weeks: daysInYearAccurate / 28,
+ days: daysInYearAccurate / 4,
+ hours: (daysInYearAccurate * 24) / 4,
+ minutes: (daysInYearAccurate * 24 * 60) / 4,
+ seconds: (daysInYearAccurate * 24 * 60 * 60) / 4,
+ milliseconds: (daysInYearAccurate * 24 * 60 * 60 * 1000) / 4,
+ },
+ months: {
+ weeks: daysInMonthAccurate / 7,
+ days: daysInMonthAccurate,
+ hours: daysInMonthAccurate * 24,
+ minutes: daysInMonthAccurate * 24 * 60,
+ seconds: daysInMonthAccurate * 24 * 60 * 60,
+ milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1000,
},
- lowOrderMatrix
- );
+ ...lowOrderMatrix,
+ };
// units ordered by size
const orderedUnits = [
@@ -111,7 +108,7 @@ const orderedUnits = [
"hours",
"minutes",
"seconds",
- "milliseconds"
+ "milliseconds",
];
const reverseUnits = orderedUnits.slice(0).reverse();
@@ -120,9 +117,10 @@ const reverseUnits = orderedUnits.slice(0).reverse();
function clone(dur, alts, clear = false) {
// deep merge for vals
const conf = {
- values: clear ? alts.values : Object.assign({}, dur.values, alts.values || {}),
+ values: clear ? alts.values : { ...dur.values, ...(alts.values || {}) },
loc: dur.loc.clone(alts.loc),
- conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
+ conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy,
+ matrix: alts.matrix || dur.matrix,
};
return new Duration(conf);
}
@@ -157,16 +155,27 @@ function normalizeValues(matrix, vals) {
}, null);
}
+// Remove all properties with a value of 0 from an object
+function removeZeroes(vals) {
+ const newVals = {};
+ for (const [key, value] of Object.entries(vals)) {
+ if (value !== 0) {
+ newVals[key] = value;
+ }
+ }
+ return newVals;
+}
+
/**
- * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". Conceptually, it's just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime.plus} to add a Duration object to a DateTime, producing another DateTime.
+ * A Duration object represents a period of time, like "2 months" or "1 day, 1 hour". Conceptually, it's just a map of units to their quantities, accompanied by some additional configuration and methods for creating, parsing, interrogating, transforming, and formatting them. They can be used on their own or in conjunction with other Luxon types; for example, you can use {@link DateTime#plus} to add a Duration object to a DateTime, producing another DateTime.
*
* Here is a brief overview of commonly used methods and getters in Duration:
*
* * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}.
- * * **Unit values** See the {@link Duration.years}, {@link Duration.months}, {@link Duration.weeks}, {@link Duration.days}, {@link Duration.hours}, {@link Duration.minutes}, {@link Duration.seconds}, {@link Duration.milliseconds} accessors.
- * * **Configuration** See {@link Duration.locale} and {@link Duration.numberingSystem} accessors.
- * * **Transformation** To create new Durations out of old ones use {@link Duration.plus}, {@link Duration.minus}, {@link Duration.normalize}, {@link Duration.set}, {@link Duration.reconfigure}, {@link Duration.shiftTo}, and {@link Duration.negate}.
- * * **Output** To convert the Duration into other representations, see {@link Duration.as}, {@link Duration.toISO}, {@link Duration.toFormat}, and {@link Duration.toJSON}
+ * * **Unit values** See the {@link Duration#years}, {@link Duration#months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes}, {@link Duration#seconds}, {@link Duration#milliseconds} accessors.
+ * * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors.
+ * * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure}, {@link Duration#shiftTo}, and {@link Duration#negate}.
+ * * **Output** To convert the Duration into other representations, see {@link Duration#as}, {@link Duration#toISO}, {@link Duration#toFormat}, and {@link Duration#toJSON}
*
* There's are more methods documented below. In addition, for more information on subtler topics like internationalization and validity, see the external documentation.
*/
@@ -176,6 +185,12 @@ export default class Duration {
*/
constructor(config) {
const accurate = config.conversionAccuracy === "longterm" || false;
+ let matrix = accurate ? accurateMatrix : casualMatrix;
+
+ if (config.matrix) {
+ matrix = config.matrix;
+ }
+
/**
* @access private
*/
@@ -195,7 +210,7 @@ export default class Duration {
/**
* @access private
*/
- this.matrix = accurate ? accurateMatrix : casualMatrix;
+ this.matrix = matrix;
/**
* @access private
*/
@@ -212,7 +227,7 @@ export default class Duration {
* @return {Duration}
*/
static fromMillis(count, opts) {
- return Duration.fromObject(Object.assign({ milliseconds: count }, opts));
+ return Duration.fromObject({ milliseconds: count }, opts);
}
/**
@@ -228,12 +243,14 @@ export default class Duration {
* @param {number} obj.minutes
* @param {number} obj.seconds
* @param {number} obj.milliseconds
- * @param {string} [obj.locale='en-US'] - the locale to use
- * @param {string} obj.numberingSystem - the numbering system to use
- * @param {string} [obj.conversionAccuracy='casual'] - the conversion system to use
+ * @param {Object} [opts=[]] - options for creating this Duration
+ * @param {string} [opts.locale='en-US'] - the locale to use
+ * @param {string} opts.numberingSystem - the numbering system to use
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
+ * @param {string} [opts.matrix=Object] - the custom conversion system to use
* @return {Duration}
*/
- static fromObject(obj) {
+ static fromObject(obj, opts = {}) {
if (obj == null || typeof obj !== "object") {
throw new InvalidArgumentError(
`Duration.fromObject: argument expected to be an object, got ${
@@ -241,25 +258,47 @@ export default class Duration {
}`
);
}
+
return new Duration({
- values: normalizeObject(obj, Duration.normalizeUnit, [
- "locale",
- "numberingSystem",
- "conversionAccuracy",
- "zone" // a bit of debt; it's super inconvenient internally not to be able to blindly pass this
- ]),
- loc: Locale.fromObject(obj),
- conversionAccuracy: obj.conversionAccuracy
+ values: normalizeObject(obj, Duration.normalizeUnit),
+ loc: Locale.fromObject(opts),
+ conversionAccuracy: opts.conversionAccuracy,
+ matrix: opts.matrix,
});
}
/**
+ * Create a Duration from DurationLike.
+ *
+ * @param {Object | number | Duration} durationLike
+ * One of:
+ * - object with keys like 'years' and 'hours'.
+ * - number representing milliseconds
+ * - Duration instance
+ * @return {Duration}
+ */
+ static fromDurationLike(durationLike) {
+ if (isNumber(durationLike)) {
+ return Duration.fromMillis(durationLike);
+ } else if (Duration.isDuration(durationLike)) {
+ return durationLike;
+ } else if (typeof durationLike === "object") {
+ return Duration.fromObject(durationLike);
+ } else {
+ throw new InvalidArgumentError(
+ `Unknown duration argument ${durationLike} of type ${typeof durationLike}`
+ );
+ }
+ }
+
+ /**
* Create a Duration from an ISO 8601 duration string.
* @param {string} text - text to parse
* @param {Object} opts - options for parsing
* @param {string} [opts.locale='en-US'] - the locale to use
* @param {string} opts.numberingSystem - the numbering system to use
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
+ * @param {string} [opts.matrix=Object] - the preset conversion system to use
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations
* @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
* @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
@@ -269,8 +308,7 @@ export default class Duration {
static fromISO(text, opts) {
const [parsed] = parseISODuration(text);
if (parsed) {
- const obj = Object.assign(parsed, opts);
- return Duration.fromObject(obj);
+ return Duration.fromObject(parsed, opts);
} else {
return Duration.invalid("unparsable", `the input "${text}" can't be parsed as ISO 8601`);
}
@@ -282,7 +320,8 @@ export default class Duration {
* @param {Object} opts - options for parsing
* @param {string} [opts.locale='en-US'] - the locale to use
* @param {string} opts.numberingSystem - the numbering system to use
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
+ * @param {string} [opts.matrix=Object] - the conversion system to use
* @see https://en.wikipedia.org/wiki/ISO_8601#Times
* @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
* @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
@@ -294,8 +333,7 @@ export default class Duration {
static fromISOTime(text, opts) {
const [parsed] = parseISOTimeOnly(text);
if (parsed) {
- const obj = Object.assign(parsed, opts);
- return Duration.fromObject(obj);
+ return Duration.fromObject(parsed, opts);
} else {
return Duration.invalid("unparsable", `the input "${text}" can't be parsed as ISO 8601`);
}
@@ -343,7 +381,7 @@ export default class Duration {
second: "seconds",
seconds: "seconds",
millisecond: "milliseconds",
- milliseconds: "milliseconds"
+ milliseconds: "milliseconds",
}[unit ? unit.toLowerCase() : unit];
if (!normalized) throw new InvalidUnitError(unit);
@@ -384,11 +422,13 @@ export default class Duration {
* * `m` for minutes
* * `h` for hours
* * `d` for days
+ * * `w` for weeks
* * `M` for months
* * `y` for years
* Notes:
* * Add padding by repeating the token, e.g. "yy" pads the years to two digits, "hhhh" pads the hours out to four digits
- * * The duration will be converted to the set of units in the format string using {@link Duration.shiftTo} and the Durations's conversion accuracy setting.
+ * * Tokens can be escaped by wrapping with single quotes.
+ * * The duration will be converted to the set of units in the format string using {@link Duration#shiftTo} and the Durations's conversion accuracy setting.
* @param {string} fmt - the format string
* @param {Object} opts - options
* @param {boolean} [opts.floor=true] - floor numerical values
@@ -399,32 +439,54 @@ export default class Duration {
*/
toFormat(fmt, opts = {}) {
// reverse-compat since 1.2; we always round down now, never up, and we do it by default
- const fmtOpts = Object.assign({}, opts, {
- floor: opts.round !== false && opts.floor !== false
- });
+ const fmtOpts = {
+ ...opts,
+ floor: opts.round !== false && opts.floor !== false,
+ };
return this.isValid
? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt)
: INVALID;
}
/**
+ * Returns a string representation of a Duration with all units included.
+ * To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant.
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
+ * @param opts - On option object to override the formatting. Accepts the same keys as the options parameter of the native `Int.NumberFormat` constructor, as well as `listStyle`.
+ * @example
+ * ```js
+ * var dur = Duration.fromObject({ days: 1, hours: 5, minutes: 6 })
+ * dur.toHuman() //=> '1 day, 5 hours, 6 minutes'
+ * dur.toHuman({ listStyle: "long" }) //=> '1 day, 5 hours, and 6 minutes'
+ * dur.toHuman({ unitDisplay: "short" }) //=> '1 day, 5 hr, 6 min'
+ * ```
+ */
+ toHuman(opts = {}) {
+ const l = orderedUnits
+ .map((unit) => {
+ const val = this.values[unit];
+ if (isUndefined(val)) {
+ return null;
+ }
+ return this.loc
+ .numberFormatter({ style: "unit", unitDisplay: "long", ...opts, unit: unit.slice(0, -1) })
+ .format(val);
+ })
+ .filter((n) => n);
+
+ return this.loc
+ .listFormatter({ type: "conjunction", style: opts.listStyle || "narrow", ...opts })
+ .format(l);
+ }
+
+ /**
* Returns a JavaScript object with this Duration's values.
- * @param opts - options for generating the object
- * @param {boolean} [opts.includeConfig=false] - include configuration attributes in the output
* @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 }
* @return {Object}
*/
- toObject(opts = {}) {
+ toObject() {
if (!this.isValid) return {};
-
- const base = Object.assign({}, this.values);
-
- if (opts.includeConfig) {
- base.conversionAccuracy = this.conversionAccuracy;
- base.numberingSystem = this.loc.numberingSystem;
- base.locale = this.loc.locale;
- }
- return base;
+ return { ...this.values };
}
/**
@@ -480,15 +542,13 @@ export default class Duration {
const millis = this.toMillis();
if (millis < 0 || millis >= 86400000) return null;
- opts = Object.assign(
- {
- suppressMilliseconds: false,
- suppressSeconds: false,
- includePrefix: false,
- format: "extended"
- },
- opts
- );
+ opts = {
+ suppressMilliseconds: false,
+ suppressSeconds: false,
+ includePrefix: false,
+ format: "extended",
+ ...opts,
+ };
const value = this.shiftTo("hours", "minutes", "seconds", "milliseconds");
@@ -550,7 +610,7 @@ export default class Duration {
plus(duration) {
if (!this.isValid) return this;
- const dur = friendlyDuration(duration),
+ const dur = Duration.fromDurationLike(duration),
result = {};
for (const k of orderedUnits) {
@@ -570,15 +630,15 @@ export default class Duration {
minus(duration) {
if (!this.isValid) return this;
- const dur = friendlyDuration(duration);
+ const dur = Duration.fromDurationLike(duration);
return this.plus(dur.negate());
}
/**
* Scale this Duration by the specified amount. Return a newly-constructed Duration.
* @param {function} fn - The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Must return a number.
- * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit(x => x * 2) //=> { hours: 2, minutes: 60 }
- * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnit((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
+ * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 }
+ * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hours" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
* @return {Duration}
*/
mapUnits(fn) {
@@ -612,7 +672,7 @@ export default class Duration {
set(values) {
if (!this.isValid) return this;
- const mixed = Object.assign(this.values, normalizeObject(values, Duration.normalizeUnit, []));
+ const mixed = { ...this.values, ...normalizeObject(values, Duration.normalizeUnit) };
return clone(this, { values: mixed });
}
@@ -621,14 +681,9 @@ export default class Duration {
* @example dur.reconfigure({ locale: 'en-GB' })
* @return {Duration}
*/
- reconfigure({ locale, numberingSystem, conversionAccuracy } = {}) {
- const loc = this.loc.clone({ locale, numberingSystem }),
- opts = { loc };
-
- if (conversionAccuracy) {
- opts.conversionAccuracy = conversionAccuracy;
- }
-
+ reconfigure({ locale, numberingSystem, conversionAccuracy, matrix } = {}) {
+ const loc = this.loc.clone({ locale, numberingSystem });
+ const opts = { loc, matrix, conversionAccuracy };
return clone(this, opts);
}
@@ -658,6 +713,17 @@ export default class Duration {
}
/**
+ * Rescale units to its largest representation
+ * @example Duration.fromObject({ milliseconds: 90000 }).rescale().toObject() //=> { minutes: 1, seconds: 30 }
+ * @return {Duration}
+ */
+ rescale() {
+ if (!this.isValid) return this;
+ const vals = removeZeroes(this.normalize().shiftToAll().toObject());
+ return clone(this, { values: vals }, true);
+ }
+
+ /**
* Convert this Duration into its representation in a different set of units.
* @example Duration.fromObject({ hours: 1, seconds: 30 }).shiftTo('minutes', 'milliseconds').toObject() //=> { minutes: 60, milliseconds: 30000 }
* @return {Duration}
@@ -669,7 +735,7 @@ export default class Duration {
return this;
}
- units = units.map(u => Duration.normalizeUnit(u));
+ units = units.map((u) => Duration.normalizeUnit(u));
const built = {},
accumulated = {},
@@ -695,7 +761,7 @@ export default class Duration {
const i = Math.trunc(own);
built[k] = i;
- accumulated[k] = own - i; // we'd like to absorb these fractions in another unit
+ accumulated[k] = (own * 1000 - i * 1000) / 1000;
// plus anything further down the chain that should be rolled up in to this
for (const down in vals) {
@@ -722,6 +788,25 @@ export default class Duration {
}
/**
+ * Shift this Duration to all available units.
+ * Same as shiftTo("years", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds")
+ * @return {Duration}
+ */
+ shiftToAll() {
+ if (!this.isValid) return this;
+ return this.shiftTo(
+ "years",
+ "months",
+ "weeks",
+ "days",
+ "hours",
+ "minutes",
+ "seconds",
+ "milliseconds"
+ );
+ }
+
+ /**
* Return the negative of this Duration.
* @example Duration.fromObject({ hours: 1, seconds: 30 }).negate().toObject() //=> { hours: -1, seconds: -30 }
* @return {Duration}
@@ -730,7 +815,7 @@ export default class Duration {
if (!this.isValid) return this;
const negated = {};
for (const k of Object.keys(this.values)) {
- negated[k] = -this.values[k];
+ negated[k] = this.values[k] === 0 ? 0 : -this.values[k];
}
return clone(this, { values: negated }, true);
}
@@ -861,20 +946,3 @@ export default class Duration {
return true;
}
}
-
-/**
- * @private
- */
-export function friendlyDuration(durationish) {
- if (isNumber(durationish)) {
- return Duration.fromMillis(durationish);
- } else if (Duration.isDuration(durationish)) {
- return durationish;
- } else if (typeof durationish === "object") {
- return Duration.fromObject(durationish);
- } else {
- throw new InvalidArgumentError(
- `Unknown duration argument ${durationish} of type ${typeof durationish}`
- );
- }
-}
diff --git a/npm_assets/node_modules/luxon/src/impl/conversions.js b/npm_assets/node_modules/luxon/src/impl/conversions.js
index cbe7172..bfb355f 100644
--- a/npm_assets/node_modules/luxon/src/impl/conversions.js
+++ b/npm_assets/node_modules/luxon/src/impl/conversions.js
@@ -5,7 +5,7 @@ import {
daysInYear,
daysInMonth,
weeksInWeekYear,
- isInteger
+ isInteger,
} from "./util.js";
import Invalid from "./invalid.js";
@@ -20,7 +20,14 @@ function unitOutOfRange(unit, value) {
}
function dayOfWeek(year, month, day) {
- const js = new Date(Date.UTC(year, month - 1, day)).getUTCDay();
+ const d = new Date(Date.UTC(year, month - 1, day));
+
+ if (year < 100 && year >= 0) {
+ d.setUTCFullYear(d.getUTCFullYear() - 1900);
+ }
+
+ const js = d.getUTCDay();
+
return js === 0 ? 7 : js;
}
@@ -30,7 +37,7 @@ function computeOrdinal(year, month, day) {
function uncomputeOrdinal(year, ordinal) {
const table = isLeapYear(year) ? leapLadder : nonLeapLadder,
- month0 = table.findIndex(i => i < ordinal),
+ month0 = table.findIndex((i) => i < ordinal),
day = ordinal - table[month0];
return { month: month0 + 1, day };
}
@@ -57,7 +64,7 @@ export function gregorianToWeek(gregObj) {
weekYear = year;
}
- return Object.assign({ weekYear, weekNumber, weekday }, timeObject(gregObj));
+ return { weekYear, weekNumber, weekday, ...timeObject(gregObj) };
}
export function weekToGregorian(weekData) {
@@ -79,22 +86,19 @@ export function weekToGregorian(weekData) {
}
const { month, day } = uncomputeOrdinal(year, ordinal);
-
- return Object.assign({ year, month, day }, timeObject(weekData));
+ return { year, month, day, ...timeObject(weekData) };
}
export function gregorianToOrdinal(gregData) {
- const { year, month, day } = gregData,
- ordinal = computeOrdinal(year, month, day);
-
- return Object.assign({ year, ordinal }, timeObject(gregData));
+ const { year, month, day } = gregData;
+ const ordinal = computeOrdinal(year, month, day);
+ return { year, ordinal, ...timeObject(gregData) };
}
export function ordinalToGregorian(ordinalData) {
- const { year, ordinal } = ordinalData,
- { month, day } = uncomputeOrdinal(year, ordinal);
-
- return Object.assign({ year, month, day }, timeObject(ordinalData));
+ const { year, ordinal } = ordinalData;
+ const { month, day } = uncomputeOrdinal(year, ordinal);
+ return { year, month, day, ...timeObject(ordinalData) };
}
export function hasInvalidWeekData(obj) {
diff --git a/npm_assets/node_modules/luxon/src/impl/diff.js b/npm_assets/node_modules/luxon/src/impl/diff.js
index 1b8afb3..7fe389b 100644
--- a/npm_assets/node_modules/luxon/src/impl/diff.js
+++ b/npm_assets/node_modules/luxon/src/impl/diff.js
@@ -1,11 +1,7 @@
import Duration from "../duration.js";
function dayDiff(earlier, later) {
- const utcDayStart = dt =>
- dt
- .toUTC(0, { keepLocalTime: true })
- .startOf("day")
- .valueOf(),
+ const utcDayStart = (dt) => dt.toUTC(0, { keepLocalTime: true }).startOf("day").valueOf(),
ms = utcDayStart(later) - utcDayStart(earlier);
return Math.floor(Duration.fromMillis(ms).as("days"));
}
@@ -13,49 +9,48 @@ function dayDiff(earlier, later) {
function highOrderDiffs(cursor, later, units) {
const differs = [
["years", (a, b) => b.year - a.year],
- ["quarters", (a, b) => b.quarter - a.quarter],
+ ["quarters", (a, b) => b.quarter - a.quarter + (b.year - a.year) * 4],
["months", (a, b) => b.month - a.month + (b.year - a.year) * 12],
[
"weeks",
(a, b) => {
const days = dayDiff(a, b);
return (days - (days % 7)) / 7;
- }
+ },
],
- ["days", dayDiff]
+ ["days", dayDiff],
];
const results = {};
+ const earlier = cursor;
let lowestOrder, highWater;
for (const [unit, differ] of differs) {
if (units.indexOf(unit) >= 0) {
lowestOrder = unit;
- let delta = differ(cursor, later);
- highWater = cursor.plus({ [unit]: delta });
+ results[unit] = differ(cursor, later);
+ highWater = earlier.plus(results);
if (highWater > later) {
- cursor = cursor.plus({ [unit]: delta - 1 });
- delta -= 1;
+ results[unit]--;
+ cursor = earlier.plus(results);
} else {
cursor = highWater;
}
-
- results[unit] = delta;
}
}
return [cursor, results, highWater, lowestOrder];
}
-export default function(earlier, later, units, opts) {
+export default function (earlier, later, units, opts) {
let [cursor, results, highWater, lowestOrder] = highOrderDiffs(earlier, later, units);
const remainingMillis = later - cursor;
const lowerOrderUnits = units.filter(
- u => ["hours", "minutes", "seconds", "milliseconds"].indexOf(u) >= 0
+ (u) => ["hours", "minutes", "seconds", "milliseconds"].indexOf(u) >= 0
);
if (lowerOrderUnits.length === 0) {
@@ -68,7 +63,7 @@ export default function(earlier, later, units, opts) {
}
}
- const duration = Duration.fromObject(Object.assign(results, opts));
+ const duration = Duration.fromObject(results, opts);
if (lowerOrderUnits.length > 0) {
return Duration.fromMillis(remainingMillis, opts)
diff --git a/npm_assets/node_modules/luxon/src/impl/digits.js b/npm_assets/node_modules/luxon/src/impl/digits.js
index 0d081c2..6ac1bae 100644
--- a/npm_assets/node_modules/luxon/src/impl/digits.js
+++ b/npm_assets/node_modules/luxon/src/impl/digits.js
@@ -19,7 +19,7 @@ const numberingSystems = {
telu: "[\u0C66-\u0C6F]",
thai: "[\u0E50-\u0E59]",
tibt: "[\u0F20-\u0F29]",
- latn: "\\d"
+ latn: "\\d",
};
const numberingSystemsUTF16 = {
@@ -41,10 +41,9 @@ const numberingSystemsUTF16 = {
tamldec: [3046, 3055],
telu: [3174, 3183],
thai: [3664, 3673],
- tibt: [3872, 3881]
+ tibt: [3872, 3881],
};
-// eslint-disable-next-line
const hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
export function parseDigits(str) {
diff --git a/npm_assets/node_modules/luxon/src/impl/english.js b/npm_assets/node_modules/luxon/src/impl/english.js
index 0ae2069..cf93798 100644
--- a/npm_assets/node_modules/luxon/src/impl/english.js
+++ b/npm_assets/node_modules/luxon/src/impl/english.js
@@ -21,7 +21,7 @@ export const monthsLong = [
"September",
"October",
"November",
- "December"
+ "December",
];
export const monthsShort = [
@@ -36,7 +36,7 @@ export const monthsShort = [
"Sep",
"Oct",
"Nov",
- "Dec"
+ "Dec",
];
export const monthsNarrow = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"];
@@ -65,7 +65,7 @@ export const weekdaysLong = [
"Thursday",
"Friday",
"Saturday",
- "Sunday"
+ "Sunday",
];
export const weekdaysShort = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
@@ -133,7 +133,7 @@ export function formatRelativeTime(unit, count, numeric = "always", narrow = fal
days: ["day", "day", "days"],
hours: ["hour", "hr."],
minutes: ["minute", "min."],
- seconds: ["second", "sec."]
+ seconds: ["second", "sec."],
};
const lastable = ["hours", "minutes", "seconds"].indexOf(unit) === -1;
@@ -160,8 +160,8 @@ export function formatRelativeTime(unit, count, numeric = "always", narrow = fal
? lilUnits[1]
: lilUnits[2] || lilUnits[1]
: singular
- ? units[unit][0]
- : unit;
+ ? units[unit][0]
+ : unit;
return isInPast ? `${fmtValue} ${fmtUnit} ago` : `in ${fmtValue} ${fmtUnit}`;
}
@@ -178,7 +178,7 @@ export function formatString(knownFormat) {
"minute",
"second",
"timeZoneName",
- "hour12"
+ "hourCycle",
]),
key = stringify(filtered),
dateTimeHuge = "EEEE, LLLL d, yyyy, h:mm a";
diff --git a/npm_assets/node_modules/luxon/src/impl/formats.js b/npm_assets/node_modules/luxon/src/impl/formats.js
index 25210f6..f2efaad 100644
--- a/npm_assets/node_modules/luxon/src/impl/formats.js
+++ b/npm_assets/node_modules/luxon/src/impl/formats.js
@@ -9,119 +9,104 @@ const n = "numeric",
export const DATE_SHORT = {
year: n,
month: n,
- day: n
+ day: n,
};
export const DATE_MED = {
year: n,
month: s,
- day: n
+ day: n,
};
export const DATE_MED_WITH_WEEKDAY = {
year: n,
month: s,
day: n,
- weekday: s
+ weekday: s,
};
export const DATE_FULL = {
year: n,
month: l,
- day: n
+ day: n,
};
export const DATE_HUGE = {
year: n,
month: l,
day: n,
- weekday: l
+ weekday: l,
};
export const TIME_SIMPLE = {
hour: n,
- minute: n
+ minute: n,
};
export const TIME_WITH_SECONDS = {
hour: n,
minute: n,
- second: n
+ second: n,
};
export const TIME_WITH_SHORT_OFFSET = {
hour: n,
minute: n,
second: n,
- timeZoneName: s
+ timeZoneName: s,
};
export const TIME_WITH_LONG_OFFSET = {
hour: n,
minute: n,
second: n,
- timeZoneName: l
+ timeZoneName: l,
};
export const TIME_24_SIMPLE = {
hour: n,
minute: n,
- hour12: false
+ hourCycle: "h23",
};
-/**
- * {@link toLocaleString}; format like '09:30:23', always 24-hour.
- */
export const TIME_24_WITH_SECONDS = {
hour: n,
minute: n,
second: n,
- hour12: false
+ hourCycle: "h23",
};
-/**
- * {@link toLocaleString}; format like '09:30:23 EDT', always 24-hour.
- */
export const TIME_24_WITH_SHORT_OFFSET = {
hour: n,
minute: n,
second: n,
- hour12: false,
- timeZoneName: s
+ hourCycle: "h23",
+ timeZoneName: s,
};
-/**
- * {@link toLocaleString}; format like '09:30:23 Eastern Daylight Time', always 24-hour.
- */
export const TIME_24_WITH_LONG_OFFSET = {
hour: n,
minute: n,
second: n,
- hour12: false,
- timeZoneName: l
+ hourCycle: "h23",
+ timeZoneName: l,
};
-/**
- * {@link toLocaleString}; format like '10/14/1983, 9:30 AM'. Only 12-hour if the locale is.
- */
export const DATETIME_SHORT = {
year: n,
month: n,
day: n,
hour: n,
- minute: n
+ minute: n,
};
-/**
- * {@link toLocaleString}; format like '10/14/1983, 9:30:33 AM'. Only 12-hour if the locale is.
- */
export const DATETIME_SHORT_WITH_SECONDS = {
year: n,
month: n,
day: n,
hour: n,
minute: n,
- second: n
+ second: n,
};
export const DATETIME_MED = {
@@ -129,7 +114,7 @@ export const DATETIME_MED = {
month: s,
day: n,
hour: n,
- minute: n
+ minute: n,
};
export const DATETIME_MED_WITH_SECONDS = {
@@ -138,7 +123,7 @@ export const DATETIME_MED_WITH_SECONDS = {
day: n,
hour: n,
minute: n,
- second: n
+ second: n,
};
export const DATETIME_MED_WITH_WEEKDAY = {
@@ -147,7 +132,7 @@ export const DATETIME_MED_WITH_WEEKDAY = {
day: n,
weekday: s,
hour: n,
- minute: n
+ minute: n,
};
export const DATETIME_FULL = {
@@ -156,7 +141,7 @@ export const DATETIME_FULL = {
day: n,
hour: n,
minute: n,
- timeZoneName: s
+ timeZoneName: s,
};
export const DATETIME_FULL_WITH_SECONDS = {
@@ -166,7 +151,7 @@ export const DATETIME_FULL_WITH_SECONDS = {
hour: n,
minute: n,
second: n,
- timeZoneName: s
+ timeZoneName: s,
};
export const DATETIME_HUGE = {
@@ -176,7 +161,7 @@ export const DATETIME_HUGE = {
weekday: l,
hour: n,
minute: n,
- timeZoneName: l
+ timeZoneName: l,
};
export const DATETIME_HUGE_WITH_SECONDS = {
@@ -187,5 +172,5 @@ export const DATETIME_HUGE_WITH_SECONDS = {
hour: n,
minute: n,
second: n,
- timeZoneName: l
+ timeZoneName: l,
};
diff --git a/npm_assets/node_modules/luxon/src/impl/formatter.js b/npm_assets/node_modules/luxon/src/impl/formatter.js
index 87b8a2f..7fe6891 100644
--- a/npm_assets/node_modules/luxon/src/impl/formatter.js
+++ b/npm_assets/node_modules/luxon/src/impl/formatter.js
@@ -1,6 +1,6 @@
import * as English from "./english.js";
import * as Formats from "./formats.js";
-import { hasFormatToParts, padStart } from "./util.js";
+import { padStart } from "./util.js";
function stringifyTokens(splits, tokenToString) {
let s = "";
@@ -34,7 +34,7 @@ const macroTokenToFormatOpts = {
F: Formats.DATETIME_SHORT_WITH_SECONDS,
FF: Formats.DATETIME_MED_WITH_SECONDS,
FFF: Formats.DATETIME_FULL_WITH_SECONDS,
- FFFF: Formats.DATETIME_HUGE_WITH_SECONDS
+ FFFF: Formats.DATETIME_HUGE_WITH_SECONDS,
};
/**
@@ -47,6 +47,9 @@ export default class Formatter {
}
static parseFormat(fmt) {
+ // white-space is always considered a literal in user-provided formats
+ // the " " token has a special meaning (see unitForToken)
+
let current = null,
currentFull = "",
bracketed = false;
@@ -55,7 +58,7 @@ export default class Formatter {
const c = fmt.charAt(i);
if (c === "'") {
if (currentFull.length > 0) {
- splits.push({ literal: bracketed, val: currentFull });
+ splits.push({ literal: bracketed || /^\s+$/.test(currentFull), val: currentFull });
}
current = null;
currentFull = "";
@@ -66,7 +69,7 @@ export default class Formatter {
currentFull += c;
} else {
if (currentFull.length > 0) {
- splits.push({ literal: false, val: currentFull });
+ splits.push({ literal: /^\s+$/.test(currentFull), val: currentFull });
}
currentFull = c;
current = c;
@@ -74,7 +77,7 @@ export default class Formatter {
}
if (currentFull.length > 0) {
- splits.push({ literal: bracketed, val: currentFull });
+ splits.push({ literal: bracketed || /^\s+$/.test(currentFull), val: currentFull });
}
return splits;
@@ -94,22 +97,27 @@ export default class Formatter {
if (this.systemLoc === null) {
this.systemLoc = this.loc.redefaultToSystem();
}
- const df = this.systemLoc.dtFormatter(dt, Object.assign({}, this.opts, opts));
+ const df = this.systemLoc.dtFormatter(dt, { ...this.opts, ...opts });
return df.format();
}
formatDateTime(dt, opts = {}) {
- const df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
+ const df = this.loc.dtFormatter(dt, { ...this.opts, ...opts });
return df.format();
}
formatDateTimeParts(dt, opts = {}) {
- const df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
+ const df = this.loc.dtFormatter(dt, { ...this.opts, ...opts });
return df.formatToParts();
}
+ formatInterval(interval, opts = {}) {
+ const df = this.loc.dtFormatter(interval.start, { ...this.opts, ...opts });
+ return df.dtf.formatRange(interval.start.toJSDate(), interval.end.toJSDate());
+ }
+
resolvedOptions(dt, opts = {}) {
- const df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
+ const df = this.loc.dtFormatter(dt, { ...this.opts, ...opts });
return df.resolvedOptions();
}
@@ -119,7 +127,7 @@ export default class Formatter {
return padStart(n, p);
}
- const opts = Object.assign({}, this.opts);
+ const opts = { ...this.opts };
if (p > 0) {
opts.padTo = p;
@@ -130,10 +138,9 @@ export default class Formatter {
formatDateTimeFromString(dt, fmt) {
const knownEnglish = this.loc.listingMode() === "en",
- useDateTimeFormatter =
- this.loc.outputCalendar && this.loc.outputCalendar !== "gregory" && hasFormatToParts(),
+ useDateTimeFormatter = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory",
string = (opts, extract) => this.loc.extract(dt, opts, extract),
- formatOffset = opts => {
+ formatOffset = (opts) => {
if (dt.isOffsetFixed && dt.offset === 0 && opts.allowZ) {
return "Z";
}
@@ -143,7 +150,7 @@ export default class Formatter {
meridiem = () =>
knownEnglish
? English.meridiemForDateTime(dt)
- : string({ hour: "numeric", hour12: true }, "dayperiod"),
+ : string({ hour: "numeric", hourCycle: "h12" }, "dayperiod"),
month = (length, standalone) =>
knownEnglish
? English.monthForDateTime(dt, length)
@@ -155,7 +162,7 @@ export default class Formatter {
standalone ? { weekday: length } : { weekday: length, month: "long", day: "numeric" },
"weekday"
),
- maybeMacro = token => {
+ maybeMacro = (token) => {
const formatOpts = Formatter.macroTokenToFormatOpts(token);
if (formatOpts) {
return this.formatWithSystemDefault(dt, formatOpts);
@@ -163,9 +170,9 @@ export default class Formatter {
return token;
}
},
- era = length =>
+ era = (length) =>
knownEnglish ? English.eraForDateTime(dt, length) : string({ era: length }, "era"),
- tokenToString = token => {
+ tokenToString = (token) => {
// Where possible: http://cldr.unicode.org/translation/date-time-1/date-time#TOC-Standalone-vs.-Format-Styles
switch (token) {
// ms
@@ -180,6 +187,11 @@ export default class Formatter {
return this.num(dt.second);
case "ss":
return this.num(dt.second, 2);
+ // fractional seconds
+ case "uu":
+ return this.num(Math.floor(dt.millisecond / 10), 2);
+ case "uuu":
+ return this.num(Math.floor(dt.millisecond / 100));
// minutes
case "m":
return this.num(dt.minute);
@@ -347,7 +359,7 @@ export default class Formatter {
}
formatDurationFromString(dur, fmt) {
- const tokenToField = token => {
+ const tokenToField = (token) => {
switch (token[0]) {
case "S":
return "millisecond";
@@ -359,6 +371,8 @@ export default class Formatter {
return "hour";
case "d":
return "day";
+ case "w":
+ return "week";
case "M":
return "month";
case "y":
@@ -367,7 +381,7 @@ export default class Formatter {
return null;
}
},
- tokenToString = lildur => token => {
+ tokenToString = (lildur) => (token) => {
const mapped = tokenToField(token);
if (mapped) {
return this.num(lildur.get(mapped), token.length);
@@ -380,7 +394,7 @@ export default class Formatter {
(found, { literal, val }) => (literal ? found : found.concat(val)),
[]
),
- collapsed = dur.shiftTo(...realTokens.map(tokenToField).filter(t => t));
+ collapsed = dur.shiftTo(...realTokens.map(tokenToField).filter((t) => t));
return stringifyTokens(tokens, tokenToString(collapsed));
}
}
diff --git a/npm_assets/node_modules/luxon/src/impl/locale.js b/npm_assets/node_modules/luxon/src/impl/locale.js
index 44a9266..a1dcd33 100644
--- a/npm_assets/node_modules/luxon/src/impl/locale.js
+++ b/npm_assets/node_modules/luxon/src/impl/locale.js
@@ -1,10 +1,22 @@
-import { hasFormatToParts, hasIntl, padStart, roundTo, hasRelative } from "./util.js";
+import { padStart, roundTo, hasRelative, formatOffset } from "./util.js";
import * as English from "./english.js";
import Settings from "../settings.js";
import DateTime from "../datetime.js";
-import Formatter from "./formatter.js";
import IANAZone from "../zones/IANAZone.js";
+// todo - remap caching
+
+let intlLFCache = {};
+function getCachedLF(locString, opts = {}) {
+ const key = JSON.stringify([locString, opts]);
+ let dtf = intlLFCache[key];
+ if (!dtf) {
+ dtf = new Intl.ListFormat(locString, opts);
+ intlLFCache[key] = dtf;
+ }
+ return dtf;
+}
+
let intlDTCache = {};
function getCachedDTF(locString, opts = {}) {
const key = JSON.stringify([locString, opts]);
@@ -43,13 +55,8 @@ let sysLocaleCache = null;
function systemLocale() {
if (sysLocaleCache) {
return sysLocaleCache;
- } else if (hasIntl()) {
- const computedSys = new Intl.DateTimeFormat().resolvedOptions().locale;
- // node sometimes defaults to "und". Override that because that is dumb
- sysLocaleCache = !computedSys || computedSys === "und" ? "en-US" : computedSys;
- return sysLocaleCache;
} else {
- sysLocaleCache = "en-US";
+ sysLocaleCache = new Intl.DateTimeFormat().resolvedOptions().locale;
return sysLocaleCache;
}
}
@@ -63,42 +70,50 @@ function parseLocaleString(localeStr) {
// b) if it does, use Intl to resolve everything
// c) if Intl fails, try again without the -u
+ // private subtags and unicode subtags have ordering requirements,
+ // and we're not properly parsing this, so just strip out the
+ // private ones if they exist.
+ const xIndex = localeStr.indexOf("-x-");
+ if (xIndex !== -1) {
+ localeStr = localeStr.substring(0, xIndex);
+ }
+
const uIndex = localeStr.indexOf("-u-");
if (uIndex === -1) {
return [localeStr];
} else {
let options;
- const smaller = localeStr.substring(0, uIndex);
+ let selectedStr;
try {
options = getCachedDTF(localeStr).resolvedOptions();
+ selectedStr = localeStr;
} catch (e) {
+ const smaller = localeStr.substring(0, uIndex);
options = getCachedDTF(smaller).resolvedOptions();
+ selectedStr = smaller;
}
const { numberingSystem, calendar } = options;
- // return the smaller one so that we can append the calendar and numbering overrides to it
- return [smaller, numberingSystem, calendar];
+ return [selectedStr, numberingSystem, calendar];
}
}
function intlConfigString(localeStr, numberingSystem, outputCalendar) {
- if (hasIntl()) {
- if (outputCalendar || numberingSystem) {
+ if (outputCalendar || numberingSystem) {
+ if (!localeStr.includes("-u-")) {
localeStr += "-u";
+ }
- if (outputCalendar) {
- localeStr += `-ca-${outputCalendar}`;
- }
+ if (outputCalendar) {
+ localeStr += `-ca-${outputCalendar}`;
+ }
- if (numberingSystem) {
- localeStr += `-nu-${numberingSystem}`;
- }
- return localeStr;
- } else {
- return localeStr;
+ if (numberingSystem) {
+ localeStr += `-nu-${numberingSystem}`;
}
+ return localeStr;
} else {
- return [];
+ return localeStr;
}
}
@@ -140,7 +155,7 @@ function supportsFastNumbers(loc) {
loc.numberingSystem === "latn" ||
!loc.locale ||
loc.locale.startsWith("en") ||
- (hasIntl() && new Intl.DateTimeFormat(loc.intl).resolvedOptions().numberingSystem === "latn")
+ new Intl.DateTimeFormat(loc.intl).resolvedOptions().numberingSystem === "latn"
);
}
}
@@ -154,8 +169,10 @@ class PolyNumberFormatter {
this.padTo = opts.padTo || 0;
this.floor = opts.floor || false;
- if (!forceSimple && hasIntl()) {
- const intlOpts = { useGrouping: false };
+ const { padTo, floor, ...otherOpts } = opts;
+
+ if (!forceSimple || Object.keys(otherOpts).length > 0) {
+ const intlOpts = { useGrouping: false, ...opts };
if (opts.padTo > 0) intlOpts.minimumIntegerDigits = opts.padTo;
this.inf = getCachedINF(intl, intlOpts);
}
@@ -180,10 +197,13 @@ class PolyNumberFormatter {
class PolyDateFormatter {
constructor(dt, intl, opts) {
this.opts = opts;
- this.hasIntl = hasIntl();
+ this.originalZone = undefined;
- let z;
- if (dt.zone.universal && this.hasIntl) {
+ let z = undefined;
+ if (this.opts.timeZone) {
+ // Don't apply any workarounds if a timeZone is explicitly provided in opts
+ this.dt = dt;
+ } else if (dt.zone.type === "fixed") {
// UTC-8 or Etc/UTC-8 are not part of tzdata, only Etc/GMT+8 and the like.
// That is why fixed-offset TZ is set to that unless it is:
// 1. Representing offset 0 when UTC is used to maintain previous behavior and does not become GMT.
@@ -192,71 +212,68 @@ class PolyDateFormatter {
// - < Etc/GMT-14, > Etc/GMT+12, and 30-minute or 45-minute offsets are not part of tzdata
const gmtOffset = -1 * (dt.offset / 60);
const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
- const isOffsetZoneSupported = IANAZone.isValidZone(offsetZ);
- if (dt.offset !== 0 && isOffsetZoneSupported) {
+ if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
z = offsetZ;
this.dt = dt;
} else {
- // Not all fixed-offset zones like Etc/+4:30 are present in tzdata.
- // So we have to make do. Two cases:
- // 1. The format options tell us to show the zone. We can't do that, so the best
- // we can do is format the date in UTC.
- // 2. The format options don't tell us to show the zone. Then we can adjust them
- // the time and tell the formatter to show it to us in UTC, so that the time is right
- // and the bad zone doesn't show up.
+ // Not all fixed-offset zones like Etc/+4:30 are present in tzdata so
+ // we manually apply the offset and substitute the zone as needed.
z = "UTC";
- if (opts.timeZoneName) {
- this.dt = dt;
- } else {
- this.dt = dt.offset === 0 ? dt : DateTime.fromMillis(dt.ts + dt.offset * 60 * 1000);
- }
+ this.dt = dt.offset === 0 ? dt : dt.setZone("UTC").plus({ minutes: dt.offset });
+ this.originalZone = dt.zone;
}
- } else if (dt.zone.type === "local") {
+ } else if (dt.zone.type === "system") {
this.dt = dt;
- } else {
+ } else if (dt.zone.type === "iana") {
this.dt = dt;
z = dt.zone.name;
+ } else {
+ // Custom zones can have any offset / offsetName so we just manually
+ // apply the offset and substitute the zone as needed.
+ z = "UTC";
+ this.dt = dt.setZone("UTC").plus({ minutes: dt.offset });
+ this.originalZone = dt.zone;
}
- if (this.hasIntl) {
- const intlOpts = Object.assign({}, this.opts);
- if (z) {
- intlOpts.timeZone = z;
- }
- this.dtf = getCachedDTF(intl, intlOpts);
- }
+ const intlOpts = { ...this.opts };
+ intlOpts.timeZone = intlOpts.timeZone || z;
+ this.dtf = getCachedDTF(intl, intlOpts);
}
format() {
- if (this.hasIntl) {
- return this.dtf.format(this.dt.toJSDate());
- } else {
- const tokenFormat = English.formatString(this.opts),
- loc = Locale.create("en-US");
- return Formatter.create(loc).formatDateTimeFromString(this.dt, tokenFormat);
+ if (this.originalZone) {
+ // If we have to substitute in the actual zone name, we have to use
+ // formatToParts so that the timezone can be replaced.
+ return this.formatToParts()
+ .map(({ value }) => value)
+ .join("");
}
+ return this.dtf.format(this.dt.toJSDate());
}
formatToParts() {
- if (this.hasIntl && hasFormatToParts()) {
- return this.dtf.formatToParts(this.dt.toJSDate());
- } else {
- // This is kind of a cop out. We actually could do this for English. However, we couldn't do it for intl strings
- // and IMO it's too weird to have an uncanny valley like that
- return [];
+ const parts = this.dtf.formatToParts(this.dt.toJSDate());
+ if (this.originalZone) {
+ return parts.map((part) => {
+ if (part.type === "timeZoneName") {
+ const offsetName = this.originalZone.offsetName(this.dt.ts, {
+ locale: this.dt.locale,
+ format: this.opts.timeZoneName,
+ });
+ return {
+ ...part,
+ value: offsetName,
+ };
+ } else {
+ return part;
+ }
+ });
}
+ return parts;
}
resolvedOptions() {
- if (this.hasIntl) {
- return this.dtf.resolvedOptions();
- } else {
- return {
- locale: "en-US",
- numberingSystem: "latn",
- outputCalendar: "gregory"
- };
- }
+ return this.dtf.resolvedOptions();
}
}
@@ -265,7 +282,7 @@ class PolyDateFormatter {
*/
class PolyRelFormatter {
constructor(intl, isEnglish, opts) {
- this.opts = Object.assign({ style: "long" }, opts);
+ this.opts = { style: "long", ...opts };
if (!isEnglish && hasRelative()) {
this.rtf = getCachedRTF(intl, opts);
}
@@ -298,11 +315,11 @@ export default class Locale {
}
static create(locale, numberingSystem, outputCalendar, defaultToEN = false) {
- const specifiedLocale = locale || Settings.defaultLocale,
- // the system locale is useful for human readable strings but annoying for parsing/formatting known formats
- localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale()),
- numberingSystemR = numberingSystem || Settings.defaultNumberingSystem,
- outputCalendarR = outputCalendar || Settings.defaultOutputCalendar;
+ const specifiedLocale = locale || Settings.defaultLocale;
+ // the system locale is useful for human readable strings but annoying for parsing/formatting known formats
+ const localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale());
+ const numberingSystemR = numberingSystem || Settings.defaultNumberingSystem;
+ const outputCalendarR = outputCalendar || Settings.defaultOutputCalendar;
return new Locale(localeR, numberingSystemR, outputCalendarR, specifiedLocale);
}
@@ -342,21 +359,12 @@ export default class Locale {
return this.fastNumbersCached;
}
- listingMode(defaultOK = true) {
- const intl = hasIntl(),
- hasFTP = intl && hasFormatToParts(),
- isActuallyEn = this.isEnglish(),
- hasNoWeirdness =
- (this.numberingSystem === null || this.numberingSystem === "latn") &&
- (this.outputCalendar === null || this.outputCalendar === "gregory");
-
- if (!hasFTP && !(isActuallyEn && hasNoWeirdness) && !defaultOK) {
- return "error";
- } else if (!hasFTP || (isActuallyEn && hasNoWeirdness)) {
- return "en";
- } else {
- return "intl";
- }
+ listingMode() {
+ const isActuallyEn = this.isEnglish();
+ const hasNoWeirdness =
+ (this.numberingSystem === null || this.numberingSystem === "latn") &&
+ (this.outputCalendar === null || this.outputCalendar === "gregory");
+ return isActuallyEn && hasNoWeirdness ? "en" : "intl";
}
clone(alts) {
@@ -373,11 +381,11 @@ export default class Locale {
}
redefaultToEN(alts = {}) {
- return this.clone(Object.assign({}, alts, { defaultToEN: true }));
+ return this.clone({ ...alts, defaultToEN: true });
}
redefaultToSystem(alts = {}) {
- return this.clone(Object.assign({}, alts, { defaultToEN: false }));
+ return this.clone({ ...alts, defaultToEN: false });
}
months(length, format = false, defaultOK = true) {
@@ -385,7 +393,7 @@ export default class Locale {
const intl = format ? { month: length, day: "numeric" } : { month: length },
formatStr = format ? "format" : "standalone";
if (!this.monthsCache[formatStr][length]) {
- this.monthsCache[formatStr][length] = mapMonths(dt => this.extract(dt, intl, "month"));
+ this.monthsCache[formatStr][length] = mapMonths((dt) => this.extract(dt, intl, "month"));
}
return this.monthsCache[formatStr][length];
});
@@ -398,7 +406,7 @@ export default class Locale {
: { weekday: length },
formatStr = format ? "format" : "standalone";
if (!this.weekdaysCache[formatStr][length]) {
- this.weekdaysCache[formatStr][length] = mapWeekdays(dt =>
+ this.weekdaysCache[formatStr][length] = mapWeekdays((dt) =>
this.extract(dt, intl, "weekday")
);
}
@@ -416,9 +424,9 @@ export default class Locale {
// In theory there could be aribitrary day periods. We're gonna assume there are exactly two
// for AM and PM. This is probably wrong, but it's makes parsing way easier.
if (!this.meridiemCache) {
- const intl = { hour: "numeric", hour12: true };
+ const intl = { hour: "numeric", hourCycle: "h12" };
this.meridiemCache = [DateTime.utc(2016, 11, 13, 9), DateTime.utc(2016, 11, 13, 19)].map(
- dt => this.extract(dt, intl, "dayperiod")
+ (dt) => this.extract(dt, intl, "dayperiod")
);
}
@@ -434,7 +442,7 @@ export default class Locale {
// This is problematic. Different calendars are going to define eras totally differently. What I need is the minimum set of dates
// to definitely enumerate them.
if (!this.eraCache[length]) {
- this.eraCache[length] = [DateTime.utc(-40, 1, 1), DateTime.utc(2017, 1, 1)].map(dt =>
+ this.eraCache[length] = [DateTime.utc(-40, 1, 1), DateTime.utc(2017, 1, 1)].map((dt) =>
this.extract(dt, intl, "era")
);
}
@@ -446,7 +454,7 @@ export default class Locale {
extract(dt, intlOpts, field) {
const df = this.dtFormatter(dt, intlOpts),
results = df.formatToParts(),
- matching = results.find(m => m.type.toLowerCase() === field);
+ matching = results.find((m) => m.type.toLowerCase() === field);
return matching ? matching.value : null;
}
@@ -464,11 +472,15 @@ export default class Locale {
return new PolyRelFormatter(this.intl, this.isEnglish(), opts);
}
+ listFormatter(opts = {}) {
+ return getCachedLF(this.intl, opts);
+ }
+
isEnglish() {
return (
this.locale === "en" ||
this.locale.toLowerCase() === "en-us" ||
- (hasIntl() && new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us"))
+ new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us")
);
}
diff --git a/npm_assets/node_modules/luxon/src/impl/regexParser.js b/npm_assets/node_modules/luxon/src/impl/regexParser.js
index 0b0297b..ab09586 100644
--- a/npm_assets/node_modules/luxon/src/impl/regexParser.js
+++ b/npm_assets/node_modules/luxon/src/impl/regexParser.js
@@ -3,8 +3,8 @@ import {
signedOffset,
parseInteger,
parseMillis,
- ianaRegex,
- isUndefined
+ isUndefined,
+ parseFloating,
} from "./util.js";
import * as English from "./english.js";
import FixedOffsetZone from "../zones/fixedOffsetZone.js";
@@ -20,18 +20,20 @@ import IANAZone from "../zones/IANAZone.js";
* Some extractions are super dumb and simpleParse and fromStrings help DRY them.
*/
+const ianaRegex = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
+
function combineRegexes(...regexes) {
const full = regexes.reduce((f, r) => f + r.source, "");
return RegExp(`^${full}$`);
}
function combineExtractors(...extractors) {
- return m =>
+ return (m) =>
extractors
.reduce(
([mergedVals, mergedZone, cursor], ex) => {
const [val, zone, next] = ex(m, cursor);
- return [Object.assign(mergedVals, val), mergedZone || zone, next];
+ return [{ ...mergedVals, ...val }, zone || mergedZone, next];
},
[{}, null, 1]
)
@@ -65,20 +67,21 @@ function simpleParse(...keys) {
}
// ISO and SQL parsing
-const offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,
- isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,
- isoTimeRegex = RegExp(`${isoTimeBaseRegex.source}${offsetRegex.source}?`),
- isoTimeExtensionRegex = RegExp(`(?:T${isoTimeRegex.source})?`),
- isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,
- isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/,
- isoOrdinalRegex = /(\d{4})-?(\d{3})/,
- extractISOWeekData = simpleParse("weekYear", "weekNumber", "weekDay"),
- extractISOOrdinalData = simpleParse("year", "ordinal"),
- sqlYmdRegex = /(\d{4})-(\d\d)-(\d\d)/, // dumbed-down version of the ISO one
- sqlTimeRegex = RegExp(
- `${isoTimeBaseRegex.source} ?(?:${offsetRegex.source}|(${ianaRegex.source}))?`
- ),
- sqlTimeExtensionRegex = RegExp(`(?: ${sqlTimeRegex.source})?`);
+const offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/;
+const isoExtendedZone = `(?:${offsetRegex.source}?(?:\\[(${ianaRegex.source})\\])?)?`;
+const isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/;
+const isoTimeRegex = RegExp(`${isoTimeBaseRegex.source}${isoExtendedZone}`);
+const isoTimeExtensionRegex = RegExp(`(?:T${isoTimeRegex.source})?`);
+const isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/;
+const isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/;
+const isoOrdinalRegex = /(\d{4})-?(\d{3})/;
+const extractISOWeekData = simpleParse("weekYear", "weekNumber", "weekDay");
+const extractISOOrdinalData = simpleParse("year", "ordinal");
+const sqlYmdRegex = /(\d{4})-(\d\d)-(\d\d)/; // dumbed-down version of the ISO one
+const sqlTimeRegex = RegExp(
+ `${isoTimeBaseRegex.source} ?(?:${offsetRegex.source}|(${ianaRegex.source}))?`
+);
+const sqlTimeExtensionRegex = RegExp(`(?: ${sqlTimeRegex.source})?`);
function int(match, pos, fallback) {
const m = match[pos];
@@ -89,7 +92,7 @@ function extractISOYmd(match, cursor) {
const item = {
year: int(match, cursor),
month: int(match, cursor + 1, 1),
- day: int(match, cursor + 2, 1)
+ day: int(match, cursor + 2, 1),
};
return [item, null, cursor + 3];
@@ -100,7 +103,7 @@ function extractISOTime(match, cursor) {
hours: int(match, cursor, 0),
minutes: int(match, cursor + 1, 0),
seconds: int(match, cursor + 2, 0),
- milliseconds: parseMillis(match[cursor + 3])
+ milliseconds: parseMillis(match[cursor + 3]),
};
return [item, null, cursor + 4];
@@ -124,20 +127,12 @@ const isoTimeOnly = RegExp(`^T?${isoTimeBaseRegex.source}$`);
// ISO duration parsing
-const isoDuration = /^-?P(?:(?:(-?\d{1,9})Y)?(?:(-?\d{1,9})M)?(?:(-?\d{1,9})W)?(?:(-?\d{1,9})D)?(?:T(?:(-?\d{1,9})H)?(?:(-?\d{1,9})M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,9}))?S)?)?)$/;
+const isoDuration =
+ /^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;
function extractISODuration(match) {
- const [
- s,
- yearStr,
- monthStr,
- weekStr,
- dayStr,
- hourStr,
- minuteStr,
- secondStr,
- millisecondsStr
- ] = match;
+ const [s, yearStr, monthStr, weekStr, dayStr, hourStr, minuteStr, secondStr, millisecondsStr] =
+ match;
const hasNegativePrefix = s[0] === "-";
const negativeSeconds = secondStr && secondStr[0] === "-";
@@ -147,15 +142,15 @@ function extractISODuration(match) {
return [
{
- years: maybeNegate(parseInteger(yearStr)),
- months: maybeNegate(parseInteger(monthStr)),
- weeks: maybeNegate(parseInteger(weekStr)),
- days: maybeNegate(parseInteger(dayStr)),
- hours: maybeNegate(parseInteger(hourStr)),
- minutes: maybeNegate(parseInteger(minuteStr)),
- seconds: maybeNegate(parseInteger(secondStr), secondStr === "-0"),
- milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds)
- }
+ years: maybeNegate(parseFloating(yearStr)),
+ months: maybeNegate(parseFloating(monthStr)),
+ weeks: maybeNegate(parseFloating(weekStr)),
+ days: maybeNegate(parseFloating(dayStr)),
+ hours: maybeNegate(parseFloating(hourStr)),
+ minutes: maybeNegate(parseFloating(minuteStr)),
+ seconds: maybeNegate(parseFloating(secondStr), secondStr === "-0"),
+ milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds),
+ },
];
}
@@ -171,7 +166,7 @@ const obsOffsets = {
MDT: -6 * 60,
MST: -7 * 60,
PDT: -7 * 60,
- PST: -8 * 60
+ PST: -8 * 60,
};
function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
@@ -180,7 +175,7 @@ function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr,
month: English.monthsShort.indexOf(monthStr) + 1,
day: parseInteger(dayStr),
hour: parseInteger(hourStr),
- minute: parseInteger(minuteStr)
+ minute: parseInteger(minuteStr),
};
if (secondStr) result.second = parseInteger(secondStr);
@@ -195,7 +190,8 @@ function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr,
}
// RFC 2822/5322
-const rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;
+const rfc2822 =
+ /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;
function extractRFC2822(match) {
const [
@@ -210,7 +206,7 @@ function extractRFC2822(match) {
obsOffset,
milOffset,
offHourStr,
- offMinuteStr
+ offMinuteStr,
] = match,
result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
@@ -229,16 +225,19 @@ function extractRFC2822(match) {
function preprocessRFC2822(s) {
// Remove comments and folding whitespace and replace multiple-spaces with a single space
return s
- .replace(/\([^)]*\)|[\n\t]/g, " ")
+ .replace(/\([^()]*\)|[\n\t]/g, " ")
.replace(/(\s\s+)/g, " ")
.trim();
}
// http date
-const rfc1123 = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,
- rfc850 = /^(Monday|Tuesday|Wedsday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,
- ascii = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;
+const rfc1123 =
+ /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,
+ rfc850 =
+ /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,
+ ascii =
+ /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;
function extractRFC1123Or850(match) {
const [, weekdayStr, dayStr, monthStr, yearStr, hourStr, minuteStr, secondStr] = match,
@@ -260,21 +259,28 @@ const isoTimeCombinedRegex = combineRegexes(isoTimeRegex);
const extractISOYmdTimeAndOffset = combineExtractors(
extractISOYmd,
extractISOTime,
- extractISOOffset
+ extractISOOffset,
+ extractIANAZone
);
const extractISOWeekTimeAndOffset = combineExtractors(
extractISOWeekData,
extractISOTime,
- extractISOOffset
+ extractISOOffset,
+ extractIANAZone
);
const extractISOOrdinalDateAndTime = combineExtractors(
extractISOOrdinalData,
extractISOTime,
- extractISOOffset
+ extractISOOffset,
+ extractIANAZone
+);
+const extractISOTimeAndOffset = combineExtractors(
+ extractISOTime,
+ extractISOOffset,
+ extractIANAZone
);
-const extractISOTimeAndOffset = combineExtractors(extractISOTime, extractISOOffset);
-/**
+/*
* @private
*/
@@ -314,12 +320,6 @@ export function parseISOTimeOnly(s) {
const sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex);
const sqlTimeCombinedRegex = combineRegexes(sqlTimeRegex);
-const extractISOYmdTimeOffsetAndIANAZone = combineExtractors(
- extractISOYmd,
- extractISOTime,
- extractISOOffset,
- extractIANAZone
-);
const extractISOTimeOffsetAndIANAZone = combineExtractors(
extractISOTime,
extractISOOffset,
@@ -329,7 +329,7 @@ const extractISOTimeOffsetAndIANAZone = combineExtractors(
export function parseSQL(s) {
return parse(
s,
- [sqlYmdWithTimeExtensionRegex, extractISOYmdTimeOffsetAndIANAZone],
+ [sqlYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset],
[sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone]
);
}
diff --git a/npm_assets/node_modules/luxon/src/impl/tokenParser.js b/npm_assets/node_modules/luxon/src/impl/tokenParser.js
index 4ca0401..5a913b0 100644
--- a/npm_assets/node_modules/luxon/src/impl/tokenParser.js
+++ b/npm_assets/node_modules/luxon/src/impl/tokenParser.js
@@ -8,12 +8,12 @@ import { ConflictingSpecificationError } from "../errors.js";
const MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
-function intUnit(regex, post = i => i) {
+function intUnit(regex, post = (i) => i) {
return { regex, deser: ([s]) => post(parseDigits(s)) };
}
const NBSP = String.fromCharCode(160);
-const spaceOrNBSP = `( |${NBSP})`;
+const spaceOrNBSP = `[ ${NBSP}]`;
const spaceOrNBSPRegExp = new RegExp(spaceOrNBSP, "g");
function fixListRegex(s) {
@@ -36,7 +36,7 @@ function oneOf(strings, startIndex) {
return {
regex: RegExp(strings.map(fixListRegex).join("|")),
deser: ([s]) =>
- strings.findIndex(i => stripInsensitivities(s) === stripInsensitivities(i)) + startIndex
+ strings.findIndex((i) => stripInsensitivities(s) === stripInsensitivities(i)) + startIndex,
};
}
}
@@ -50,7 +50,6 @@ function simple(regex) {
}
function escapeToken(value) {
- // eslint-disable-next-line no-useless-escape
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
}
@@ -66,8 +65,8 @@ function unitForToken(token, loc) {
oneToNine = digitRegex(loc, "{1,9}"),
twoToFour = digitRegex(loc, "{2,4}"),
fourToSix = digitRegex(loc, "{4,6}"),
- literal = t => ({ regex: RegExp(escapeToken(t.val)), deser: ([s]) => s, literal: true }),
- unitate = t => {
+ literal = (t) => ({ regex: RegExp(escapeToken(t.val)), deser: ([s]) => s, literal: true }),
+ unitate = (t) => {
if (token.literal) {
return literal(t);
}
@@ -142,6 +141,10 @@ function unitForToken(token, loc) {
return intUnit(three);
case "u":
return simple(oneToNine);
+ case "uu":
+ return simple(oneOrTwo);
+ case "uuu":
+ return intUnit(one);
// meridiem
case "a":
return oneOf(loc.meridiems(), 0);
@@ -177,13 +180,17 @@ function unitForToken(token, loc) {
// because we don't have any way to figure out what they are
case "z":
return simple(/[a-z_+-/]{1,256}?/i);
+ // this special-case "token" represents a place where a macro-token expanded into a white-space literal
+ // in this case we accept any non-newline white-space
+ case " ":
+ return simple(/[^\S\n\r]/);
default:
return literal(t);
}
};
const unit = unitate(token) || {
- invalidReason: MISSING_FTP
+ invalidReason: MISSING_FTP,
};
unit.token = token;
@@ -194,45 +201,50 @@ function unitForToken(token, loc) {
const partTypeStyleToTokenVal = {
year: {
"2-digit": "yy",
- numeric: "yyyyy"
+ numeric: "yyyyy",
},
month: {
numeric: "M",
"2-digit": "MM",
short: "MMM",
- long: "MMMM"
+ long: "MMMM",
},
day: {
numeric: "d",
- "2-digit": "dd"
+ "2-digit": "dd",
},
weekday: {
short: "EEE",
- long: "EEEE"
+ long: "EEEE",
},
dayperiod: "a",
dayPeriod: "a",
hour: {
numeric: "h",
- "2-digit": "hh"
+ "2-digit": "hh",
},
minute: {
numeric: "m",
- "2-digit": "mm"
+ "2-digit": "mm",
},
second: {
numeric: "s",
- "2-digit": "ss"
- }
+ "2-digit": "ss",
+ },
+ timeZoneName: {
+ long: "ZZZZZ",
+ short: "ZZZ",
+ },
};
-function tokenForPart(part, locale, formatOpts) {
+function tokenForPart(part, formatOpts) {
const { type, value } = part;
if (type === "literal") {
+ const isSpace = /^\s+$/.test(value);
return {
- literal: true,
- val: value
+ literal: !isSpace,
+ val: isSpace ? " " : value,
};
}
@@ -246,7 +258,7 @@ function tokenForPart(part, locale, formatOpts) {
if (val) {
return {
literal: false,
- val
+ val,
};
}
@@ -254,7 +266,7 @@ function tokenForPart(part, locale, formatOpts) {
}
function buildRegex(units) {
- const re = units.map(u => u.regex).reduce((f, r) => `${f}(${r.source})`, "");
+ const re = units.map((u) => u.regex).reduce((f, r) => `${f}(${r.source})`, "");
return [`^${re}$`, units];
}
@@ -281,7 +293,7 @@ function match(input, regex, handlers) {
}
function dateTimeFromMatches(matches) {
- const toField = token => {
+ const toField = (token) => {
switch (token) {
case "S":
return "millisecond";
@@ -315,13 +327,17 @@ function dateTimeFromMatches(matches) {
}
};
- let zone;
- if (!isUndefined(matches.Z)) {
- zone = new FixedOffsetZone(matches.Z);
- } else if (!isUndefined(matches.z)) {
+ let zone = null;
+ let specificOffset;
+ if (!isUndefined(matches.z)) {
zone = IANAZone.create(matches.z);
- } else {
- zone = null;
+ }
+
+ if (!isUndefined(matches.Z)) {
+ if (!zone) {
+ zone = new FixedOffsetZone(matches.Z);
+ }
+ specificOffset = matches.Z;
}
if (!isUndefined(matches.q)) {
@@ -353,7 +369,7 @@ function dateTimeFromMatches(matches) {
return r;
}, {});
- return [vals, zone];
+ return [vals, zone, specificOffset];
}
let dummyDateTimeCache = null;
@@ -372,25 +388,17 @@ function maybeExpandMacroToken(token, locale) {
}
const formatOpts = Formatter.macroTokenToFormatOpts(token.val);
+ const tokens = formatOptsToTokens(formatOpts, locale);
- if (!formatOpts) {
- return token;
- }
-
- const formatter = Formatter.create(locale, formatOpts);
- const parts = formatter.formatDateTimeParts(getDummyDateTime());
-
- const tokens = parts.map(p => tokenForPart(p, locale, formatOpts));
-
- if (tokens.includes(undefined)) {
+ if (tokens == null || tokens.includes(undefined)) {
return token;
}
return tokens;
}
-function expandMacroTokens(tokens, locale) {
- return Array.prototype.concat(...tokens.map(t => maybeExpandMacroToken(t, locale)));
+export function expandMacroTokens(tokens, locale) {
+ return Array.prototype.concat(...tokens.map((t) => maybeExpandMacroToken(t, locale)));
}
/**
@@ -399,8 +407,8 @@ function expandMacroTokens(tokens, locale) {
export function explainFromTokens(locale, input, format) {
const tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
- units = tokens.map(t => unitForToken(t, locale)),
- disqualifyingUnit = units.find(t => t.invalidReason);
+ units = tokens.map((t) => unitForToken(t, locale)),
+ disqualifyingUnit = units.find((t) => t.invalidReason);
if (disqualifyingUnit) {
return { input, tokens, invalidReason: disqualifyingUnit.invalidReason };
@@ -408,17 +416,29 @@ export function explainFromTokens(locale, input, format) {
const [regexString, handlers] = buildRegex(units),
regex = RegExp(regexString, "i"),
[rawMatches, matches] = match(input, regex, handlers),
- [result, zone] = matches ? dateTimeFromMatches(matches) : [null, null];
+ [result, zone, specificOffset] = matches
+ ? dateTimeFromMatches(matches)
+ : [null, null, undefined];
if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
throw new ConflictingSpecificationError(
"Can't include meridiem when specifying 24-hour format"
);
}
- return { input, tokens, regex, rawMatches, matches, result, zone };
+ return { input, tokens, regex, rawMatches, matches, result, zone, specificOffset };
}
}
export function parseFromTokens(locale, input, format) {
- const { result, zone, invalidReason } = explainFromTokens(locale, input, format);
- return [result, zone, invalidReason];
+ const { result, zone, specificOffset, invalidReason } = explainFromTokens(locale, input, format);
+ return [result, zone, specificOffset, invalidReason];
+}
+
+export function formatOptsToTokens(formatOpts, locale) {
+ if (!formatOpts) {
+ return null;
+ }
+
+ const formatter = Formatter.create(locale, formatOpts);
+ const parts = formatter.formatDateTimeParts(getDummyDateTime());
+ return parts.map((p) => tokenForPart(p, formatOpts));
}
diff --git a/npm_assets/node_modules/luxon/src/impl/util.js b/npm_assets/node_modules/luxon/src/impl/util.js
index 59f6f86..81bffc6 100644
--- a/npm_assets/node_modules/luxon/src/impl/util.js
+++ b/npm_assets/node_modules/luxon/src/impl/util.js
@@ -5,6 +5,7 @@
*/
import { InvalidArgumentError } from "../errors.js";
+import Settings from "../settings.js";
/**
* @private
@@ -34,18 +35,6 @@ export function isDate(o) {
// CAPABILITIES
-export function hasIntl() {
- try {
- return typeof Intl !== "undefined" && Intl.DateTimeFormat;
- } catch (e) {
- return false;
- }
-}
-
-export function hasFormatToParts() {
- return !isUndefined(Intl.DateTimeFormat.prototype.formatToParts);
-}
-
export function hasRelative() {
try {
return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat;
@@ -99,17 +88,14 @@ export function floorMod(x, n) {
}
export function padStart(input, n = 2) {
- const minus = input < 0 ? "-" : "";
- const target = minus ? input * -1 : input;
- let result;
-
- if (target.toString().length < n) {
- result = ("0".repeat(n) + target).slice(-n);
+ const isNeg = input < 0;
+ let padded;
+ if (isNeg) {
+ padded = "-" + ("" + -input).padStart(n, "0");
} else {
- result = target.toString();
+ padded = ("" + input).padStart(n, "0");
}
-
- return `${minus}${result}`;
+ return padded;
}
export function parseInteger(string) {
@@ -120,6 +106,14 @@ export function parseInteger(string) {
}
}
+export function parseFloating(string) {
+ if (isUndefined(string) || string === null || string === "") {
+ return undefined;
+ } else {
+ return parseFloat(string);
+ }
+}
+
export function parseMillis(fraction) {
// Return undefined (instead of 0) in these cases, where fraction is not set
if (isUndefined(fraction) || fraction === null || fraction === "") {
@@ -172,7 +166,10 @@ export function objToLocalTS(obj) {
// for legacy reasons, years between 0 and 99 are interpreted as 19XX; revert that
if (obj.year < 100 && obj.year >= 0) {
d = new Date(d);
- d.setUTCFullYear(d.getUTCFullYear() - 1900);
+ // set the month and day again, this is necessary because year 2000 is a leap year, but year 100 is not
+ // so if obj.year is in 99, but obj.day makes it roll over into year 100,
+ // the calculations done by Date.UTC are using year 2000 - which is incorrect
+ d.setUTCFullYear(obj.year, obj.month - 1, obj.day);
}
return +d;
}
@@ -192,7 +189,7 @@ export function weeksInWeekYear(weekYear) {
export function untruncateYear(year) {
if (year > 99) {
return year;
- } else return year > 60 ? 1900 + year : 2000 + year;
+ } else return year > Settings.twoDigitCutoffYear ? 1900 + year : 2000 + year;
}
// PARSING
@@ -200,36 +197,24 @@ export function untruncateYear(year) {
export function parseZoneInfo(ts, offsetFormat, locale, timeZone = null) {
const date = new Date(ts),
intlOpts = {
- hour12: false,
+ hourCycle: "h23",
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
- minute: "2-digit"
+ minute: "2-digit",
};
if (timeZone) {
intlOpts.timeZone = timeZone;
}
- const modified = Object.assign({ timeZoneName: offsetFormat }, intlOpts),
- intl = hasIntl();
-
- if (intl && hasFormatToParts()) {
- const parsed = new Intl.DateTimeFormat(locale, modified)
- .formatToParts(date)
- .find(m => m.type.toLowerCase() === "timezonename");
- return parsed ? parsed.value : null;
- } else if (intl) {
- // this probably doesn't work for all locales
- const without = new Intl.DateTimeFormat(locale, intlOpts).format(date),
- included = new Intl.DateTimeFormat(locale, modified).format(date),
- diffed = included.substring(without.length),
- trimmed = diffed.replace(/^[, \u200e]+/, "");
- return trimmed;
- } else {
- return null;
- }
+ const modified = { timeZoneName: offsetFormat, ...intlOpts };
+
+ const parsed = new Intl.DateTimeFormat(locale, modified)
+ .formatToParts(date)
+ .find((m) => m.type.toLowerCase() === "timezonename");
+ return parsed ? parsed.value : null;
}
// signedOffset('-5', '30') -> -330
@@ -255,11 +240,10 @@ export function asNumber(value) {
return numericValue;
}
-export function normalizeObject(obj, normalizer, nonUnitKeys) {
+export function normalizeObject(obj, normalizer) {
const normalized = {};
for (const u in obj) {
if (hasOwnProperty(obj, u)) {
- if (nonUnitKeys.indexOf(u) >= 0) continue;
const v = obj[u];
if (v === undefined || v === null) continue;
normalized[normalizer(u)] = asNumber(v);
@@ -288,5 +272,3 @@ export function formatOffset(offset, format) {
export function timeObject(obj) {
return pick(obj, ["hour", "minute", "second", "millisecond"]);
}
-
-export const ianaRegex = /[A-Za-z_+-]{1,256}(:?\/[A-Za-z_+-]{1,256}(\/[A-Za-z_+-]{1,256})?)?/;
diff --git a/npm_assets/node_modules/luxon/src/impl/zoneUtil.js b/npm_assets/node_modules/luxon/src/impl/zoneUtil.js
index c45e828..ad389db 100644
--- a/npm_assets/node_modules/luxon/src/impl/zoneUtil.js
+++ b/npm_assets/node_modules/luxon/src/impl/zoneUtil.js
@@ -8,6 +8,7 @@ import FixedOffsetZone from "../zones/fixedOffsetZone.js";
import InvalidZone from "../zones/invalidZone.js";
import { isUndefined, isString, isNumber } from "./util.js";
+import SystemZone from "../zones/systemZone.js";
export function normalizeZone(input, defaultZone) {
let offset;
@@ -17,13 +18,10 @@ export function normalizeZone(input, defaultZone) {
return input;
} else if (isString(input)) {
const lowered = input.toLowerCase();
- if (lowered === "local") return defaultZone;
+ if (lowered === "default") return defaultZone;
+ else if (lowered === "local" || lowered === "system") return SystemZone.instance;
else if (lowered === "utc" || lowered === "gmt") return FixedOffsetZone.utcInstance;
- else if ((offset = IANAZone.parseGMTOffset(input)) != null) {
- // handle Etc/GMT-4, which V8 chokes on
- return FixedOffsetZone.instance(offset);
- } else if (IANAZone.isValidSpecifier(lowered)) return IANAZone.create(input);
- else return FixedOffsetZone.parseSpecifier(lowered) || new InvalidZone(input);
+ else return FixedOffsetZone.parseSpecifier(lowered) || IANAZone.create(input);
} else if (isNumber(input)) {
return FixedOffsetZone.instance(input);
} else if (typeof input === "object" && input.offset && typeof input.offset === "number") {
diff --git a/npm_assets/node_modules/luxon/src/info.js b/npm_assets/node_modules/luxon/src/info.js
index 5197da2..d8c8e08 100644
--- a/npm_assets/node_modules/luxon/src/info.js
+++ b/npm_assets/node_modules/luxon/src/info.js
@@ -4,7 +4,7 @@ import Locale from "./impl/locale.js";
import IANAZone from "./zones/IANAZone.js";
import { normalizeZone } from "./impl/zoneUtil.js";
-import { hasFormatToParts, hasIntl, hasRelative } from "./impl/util.js";
+import { hasRelative } from "./impl/util.js";
/**
* The Info class contains static methods for retrieving general time and date related data. For example, it has methods for finding out if a time zone has a DST, for listing the months in any supported locale, and for discovering which of Luxon features are available in the current environment.
@@ -16,11 +16,9 @@ export default class Info {
* @return {boolean}
*/
static hasDST(zone = Settings.defaultZone) {
- const proto = DateTime.now()
- .setZone(zone)
- .set({ month: 12 });
+ const proto = DateTime.now().setZone(zone).set({ month: 12 });
- return !zone.universal && proto.offset !== proto.set({ month: 6 }).offset;
+ return !zone.isUniversal && proto.offset !== proto.set({ month: 6 }).offset;
}
/**
@@ -29,7 +27,7 @@ export default class Info {
* @return {boolean}
*/
static isValidIANAZone(zone) {
- return IANAZone.isValidSpecifier(zone) && IANAZone.isValidZone(zone);
+ return IANAZone.isValidZone(zone);
}
/**
@@ -39,7 +37,7 @@ export default class Info {
* * If `input` is a string containing a valid time zone name, a Zone instance
* with that name is returned.
* * If `input` is a string that doesn't refer to a known time zone, a Zone
- * instance with {@link Zone.isValid} == false is returned.
+ * instance with {@link Zone#isValid} == false is returned.
* * If `input is a number, a Zone instance with the specified fixed offset
* in minutes is returned.
* * If `input` is `null` or `undefined`, the default zone is returned.
@@ -65,7 +63,7 @@ export default class Info {
* @example Info.months('short', { locale: 'fr-CA' } )[0] //=> 'janv.'
* @example Info.months('numeric', { locale: 'ar' })[0] //=> '١'
* @example Info.months('long', { outputCalendar: 'islamic' })[0] //=> 'Rabiʻ I'
- * @return {[string]}
+ * @return {Array}
*/
static months(
length = "long",
@@ -78,14 +76,14 @@ export default class Info {
* Return an array of format month names.
* Format months differ from standalone months in that they're meant to appear next to the day of the month. In some languages, that
* changes the string.
- * See {@link months}
+ * See {@link Info#months}
* @param {string} [length='long'] - the length of the month representation, such as "numeric", "2-digit", "narrow", "short", "long"
* @param {Object} opts - options
* @param {string} [opts.locale] - the locale code
* @param {string} [opts.numberingSystem=null] - the numbering system
* @param {string} [opts.locObj=null] - an existing locale object to use
* @param {string} [opts.outputCalendar='gregory'] - the calendar
- * @return {[string]}
+ * @return {Array}
*/
static monthsFormat(
length = "long",
@@ -106,7 +104,7 @@ export default class Info {
* @example Info.weekdays('short')[0] //=> 'Mon'
* @example Info.weekdays('short', { locale: 'fr-CA' })[0] //=> 'lun.'
* @example Info.weekdays('short', { locale: 'ar' })[0] //=> 'الاثنين'
- * @return {[string]}
+ * @return {Array}
*/
static weekdays(length = "long", { locale = null, numberingSystem = null, locObj = null } = {}) {
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length);
@@ -116,13 +114,13 @@ export default class Info {
* Return an array of format week names.
* Format weekdays differ from standalone weekdays in that they're meant to appear next to more date information. In some languages, that
* changes the string.
- * See {@link weekdays}
- * @param {string} [length='long'] - the length of the weekday representation, such as "narrow", "short", "long".
+ * See {@link Info#weekdays}
+ * @param {string} [length='long'] - the length of the month representation, such as "narrow", "short", "long".
* @param {Object} opts - options
* @param {string} [opts.locale=null] - the locale code
* @param {string} [opts.numberingSystem=null] - the numbering system
* @param {string} [opts.locObj=null] - an existing locale object to use
- * @return {[string]}
+ * @return {Array}
*/
static weekdaysFormat(
length = "long",
@@ -137,7 +135,7 @@ export default class Info {
* @param {string} [opts.locale] - the locale code
* @example Info.meridiems() //=> [ 'AM', 'PM' ]
* @example Info.meridiems({ locale: 'my' }) //=> [ 'နံနက်', 'ညနေ' ]
- * @return {[string]}
+ * @return {Array}
*/
static meridiems({ locale = null } = {}) {
return Locale.create(locale).meridiems();
@@ -151,7 +149,7 @@ export default class Info {
* @example Info.eras() //=> [ 'BC', 'AD' ]
* @example Info.eras('long') //=> [ 'Before Christ', 'Anno Domini' ]
* @example Info.eras('long', { locale: 'fr' }) //=> [ 'avant Jésus-Christ', 'après Jésus-Christ' ]
- * @return {[string]}
+ * @return {Array}
*/
static eras(length = "short", { locale = null } = {}) {
return Locale.create(locale, null, "gregory").eras(length);
@@ -159,35 +157,13 @@ export default class Info {
/**
* Return the set of available features in this environment.
- * Some features of Luxon are not available in all environments. For example, on older browsers, timezone support is not available. Use this function to figure out if that's the case.
+ * Some features of Luxon are not available in all environments. For example, on older browsers, relative time formatting support is not available. Use this function to figure out if that's the case.
* Keys:
- * * `zones`: whether this environment supports IANA timezones
- * * `intlTokens`: whether this environment supports internationalized token-based formatting/parsing
- * * `intl`: whether this environment supports general internationalization
* * `relative`: whether this environment supports relative time formatting
- * @example Info.features() //=> { intl: true, intlTokens: false, zones: true, relative: false }
+ * @example Info.features() //=> { relative: false }
* @return {Object}
*/
static features() {
- let intl = false,
- intlTokens = false,
- zones = false,
- relative = false;
-
- if (hasIntl()) {
- intl = true;
- intlTokens = hasFormatToParts();
- relative = hasRelative();
-
- try {
- zones =
- new Intl.DateTimeFormat("en", { timeZone: "America/New_York" }).resolvedOptions()
- .timeZone === "America/New_York";
- } catch (e) {
- zones = false;
- }
- }
-
- return { intl, intlTokens, zones, relative };
+ return { relative: hasRelative() };
}
}
diff --git a/npm_assets/node_modules/luxon/src/interval.js b/npm_assets/node_modules/luxon/src/interval.js
index 71273fd..33caf6d 100644
--- a/npm_assets/node_modules/luxon/src/interval.js
+++ b/npm_assets/node_modules/luxon/src/interval.js
@@ -1,8 +1,10 @@
import DateTime, { friendlyDateTime } from "./datetime.js";
-import Duration, { friendlyDuration } from "./duration.js";
+import Duration from "./duration.js";
import Settings from "./settings.js";
import { InvalidArgumentError, InvalidIntervalError } from "./errors.js";
import Invalid from "./impl/invalid.js";
+import Formatter from "./impl/formatter.js";
+import * as Formats from "./impl/formats.js";
const INVALID = "Invalid Interval";
@@ -27,12 +29,12 @@ function validateStartEnd(start, end) {
*
* Here is a brief overview of the most commonly used methods and getters in Interval:
*
- * * **Creation** To create an Interval, use {@link fromDateTimes}, {@link after}, {@link before}, or {@link fromISO}.
- * * **Accessors** Use {@link start} and {@link end} to get the start and end.
- * * **Interrogation** To analyze the Interval, use {@link count}, {@link length}, {@link hasSame}, {@link contains}, {@link isAfter}, or {@link isBefore}.
- * * **Transformation** To create other Intervals out of this one, use {@link set}, {@link splitAt}, {@link splitBy}, {@link divideEqually}, {@link merge}, {@link xor}, {@link union}, {@link intersection}, or {@link difference}.
- * * **Comparison** To compare this Interval to another one, use {@link equals}, {@link overlaps}, {@link abutsStart}, {@link abutsEnd}, {@link engulfs}.
- * * **Output** To convert the Interval into other representations, see {@link toString}, {@link toISO}, {@link toISODate}, {@link toISOTime}, {@link toFormat}, and {@link toDuration}.
+ * * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}.
+ * * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end.
+ * * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}.
+ * * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval.merge}, {@link Interval.xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}.
+ * * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs}
+ * * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toLocaleString}, {@link Interval#toISO}, {@link Interval#toISODate}, {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}.
*/
export default class Interval {
/**
@@ -92,7 +94,7 @@ export default class Interval {
if (validateError == null) {
return new Interval({
start: builtStart,
- end: builtEnd
+ end: builtEnd,
});
} else {
return validateError;
@@ -106,7 +108,7 @@ export default class Interval {
* @return {Interval}
*/
static after(start, duration) {
- const dur = friendlyDuration(duration),
+ const dur = Duration.fromDurationLike(duration),
dt = friendlyDateTime(start);
return Interval.fromDateTimes(dt, dt.plus(dur));
}
@@ -118,7 +120,7 @@ export default class Interval {
* @return {Interval}
*/
static before(end, duration) {
- const dur = friendlyDuration(duration),
+ const dur = Duration.fromDurationLike(duration),
dt = friendlyDateTime(end);
return Interval.fromDateTimes(dt.minus(dur), dt);
}
@@ -127,7 +129,7 @@ export default class Interval {
* Create an Interval from an ISO 8601 string.
* Accepts `<start>/<end>`, `<start>/<duration>`, and `<duration>/<end>` formats.
* @param {string} text - the ISO string to parse
- * @param {Object} [opts] - options to pass {@link DateTime.fromISO} and optionally {@link Duration.fromISO}
+ * @param {Object} [opts] - options to pass {@link DateTime#fromISO} and optionally {@link Duration#fromISO}
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
* @return {Interval}
*/
@@ -229,7 +231,7 @@ export default class Interval {
/**
* Returns the count of minutes, hours, days, months, or years included in the Interval, even in part.
- * Unlike {@link length} this counts sections of the calendar, not periods of time, e.g. specifying 'day'
+ * Unlike {@link Interval#length} this counts sections of the calendar, not periods of time, e.g. specifying 'day'
* asks 'what dates are included in this interval?', not 'how many days long is this interval?'
* @param {string} [unit='milliseconds'] - the unit of time to count.
* @return {number}
@@ -238,7 +240,7 @@ export default class Interval {
if (!this.isValid) return NaN;
const start = this.start.startOf(unit),
end = this.end.startOf(unit);
- return Math.floor(end.diff(start, unit).get(unit)) + 1;
+ return Math.floor(end.diff(start, unit).get(unit)) + (end.valueOf() !== this.end.valueOf());
}
/**
@@ -302,14 +304,14 @@ export default class Interval {
/**
* Split this Interval at each of the specified DateTimes
- * @param {...[DateTime]} dateTimes - the unit of time to count.
- * @return {[Interval]}
+ * @param {...DateTime} dateTimes - the unit of time to count.
+ * @return {Array}
*/
splitAt(...dateTimes) {
if (!this.isValid) return [];
const sorted = dateTimes
.map(friendlyDateTime)
- .filter(d => this.contains(d))
+ .filter((d) => this.contains(d))
.sort(),
results = [];
let { s } = this,
@@ -330,10 +332,10 @@ export default class Interval {
* Split this Interval into smaller Intervals, each of the specified length.
* Left over time is grouped into a smaller interval
* @param {Duration|Object|number} duration - The length of each resulting interval.
- * @return {[Interval]}
+ * @return {Array}
*/
splitBy(duration) {
- const dur = friendlyDuration(duration);
+ const dur = Duration.fromDurationLike(duration);
if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) {
return [];
@@ -345,7 +347,7 @@ export default class Interval {
const results = [];
while (s < this.e) {
- const added = this.start.plus(dur.mapUnits(x => x * idx));
+ const added = this.start.plus(dur.mapUnits((x) => x * idx));
next = +added > +this.e ? this.e : added;
results.push(Interval.fromDateTimes(s, next));
s = next;
@@ -358,7 +360,7 @@ export default class Interval {
/**
* Split this Interval into the specified number of smaller intervals.
* @param {number} numberOfParts - The number of Intervals to divide the Interval into.
- * @return {[Interval]}
+ * @return {Array}
*/
divideEqually(numberOfParts) {
if (!this.isValid) return [];
@@ -452,22 +454,24 @@ export default class Interval {
/**
* Merge an array of Intervals into a equivalent minimal set of Intervals.
* Combines overlapping and adjacent Intervals.
- * @param {[Interval]} intervals
- * @return {[Interval]}
+ * @param {Array} intervals
+ * @return {Array}
*/
static merge(intervals) {
- const [found, final] = intervals.sort((a, b) => a.s - b.s).reduce(
- ([sofar, current], item) => {
- if (!current) {
- return [sofar, item];
- } else if (current.overlaps(item) || current.abutsStart(item)) {
- return [sofar, current.union(item)];
- } else {
- return [sofar.concat([current]), item];
- }
- },
- [[], null]
- );
+ const [found, final] = intervals
+ .sort((a, b) => a.s - b.s)
+ .reduce(
+ ([sofar, current], item) => {
+ if (!current) {
+ return [sofar, item];
+ } else if (current.overlaps(item) || current.abutsStart(item)) {
+ return [sofar, current.union(item)];
+ } else {
+ return [sofar.concat([current]), item];
+ }
+ },
+ [[], null]
+ );
if (final) {
found.push(final);
}
@@ -476,14 +480,17 @@ export default class Interval {
/**
* Return an array of Intervals representing the spans of time that only appear in one of the specified Intervals.
- * @param {[Interval]} intervals
- * @return {[Interval]}
+ * @param {Array} intervals
+ * @return {Array}
*/
static xor(intervals) {
let start = null,
currentCount = 0;
const results = [],
- ends = intervals.map(i => [{ time: i.s, type: "s" }, { time: i.e, type: "e" }]),
+ ends = intervals.map((i) => [
+ { time: i.s, type: "s" },
+ { time: i.e, type: "e" },
+ ]),
flattened = Array.prototype.concat(...ends),
arr = flattened.sort((a, b) => a.time - b.time);
@@ -507,12 +514,12 @@ export default class Interval {
/**
* Return an Interval representing the span of time in this Interval that doesn't overlap with any of the specified Intervals.
* @param {...Interval} intervals
- * @return {[Interval]}
+ * @return {Array}
*/
difference(...intervals) {
return Interval.xor([this].concat(intervals))
- .map(i => this.intersection(i))
- .filter(i => i && !i.isEmpty());
+ .map((i) => this.intersection(i))
+ .filter((i) => i && !i.isEmpty());
}
/**
@@ -525,9 +532,33 @@ export default class Interval {
}
/**
+ * Returns a localized string representing this Interval. Accepts the same options as the
+ * Intl.DateTimeFormat constructor and any presets defined by Luxon, such as
+ * {@link DateTime.DATE_FULL} or {@link DateTime.TIME_SIMPLE}. The exact behavior of this method
+ * is browser-specific, but in general it will return an appropriate representation of the
+ * Interval in the assigned locale. Defaults to the system's locale if no locale has been
+ * specified.
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
+ * @param {Object} [formatOpts=DateTime.DATE_SHORT] - Either a DateTime preset or
+ * Intl.DateTimeFormat constructor options.
+ * @param {Object} opts - Options to override the configuration of the start DateTime.
+ * @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(); //=> 11/7/2022 – 11/8/2022
+ * @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL); //=> November 7 – 8, 2022
+ * @example Interval.fromISO('2022-11-07T09:00Z/2022-11-08T09:00Z').toLocaleString(DateTime.DATE_FULL, { locale: 'fr-FR' }); //=> 7–8 novembre 2022
+ * @example Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString(DateTime.TIME_SIMPLE); //=> 6:00 – 8:00 PM
+ * @example Interval.fromISO('2022-11-07T17:00Z/2022-11-07T19:00Z').toLocaleString({ weekday: 'short', month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' }); //=> Mon, Nov 07, 6:00 – 8:00 p
+ * @return {string}
+ */
+ toLocaleString(formatOpts = Formats.DATE_SHORT, opts = {}) {
+ return this.isValid
+ ? Formatter.create(this.s.loc.clone(opts), formatOpts).formatInterval(this)
+ : INVALID;
+ }
+
+ /**
* Returns an ISO 8601-compliant string representation of this Interval.
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
- * @param {Object} opts - The same options as {@link DateTime.toISO}
+ * @param {Object} opts - The same options as {@link DateTime#toISO}
* @return {string}
*/
toISO(opts) {
@@ -550,7 +581,7 @@ export default class Interval {
* Returns an ISO 8601-compliant string representation of time of this Interval.
* The date components are ignored.
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_intervals
- * @param {Object} opts - The same options as {@link DateTime.toISO}
+ * @param {Object} opts - The same options as {@link DateTime#toISO}
* @return {string}
*/
toISOTime(opts) {
@@ -559,10 +590,14 @@ export default class Interval {
}
/**
- * Returns a string representation of this Interval formatted according to the specified format string.
- * @param {string} dateFormat - the format string. This string formats the start and end time. See {@link DateTime.toFormat} for details.
- * @param {Object} opts - options
- * @param {string} [opts.separator = ' – '] - a separator to place between the start and end representations
+ * Returns a string representation of this Interval formatted according to the specified format
+ * string. **You may not want this.** See {@link Interval#toLocaleString} for a more flexible
+ * formatting tool.
+ * @param {string} dateFormat - The format string. This string formats the start and end time.
+ * See {@link DateTime#toFormat} for details.
+ * @param {Object} opts - Options.
+ * @param {string} [opts.separator = ' – '] - A separator to place between the start and end
+ * representations.
* @return {string}
*/
toFormat(dateFormat, { separator = " – " } = {}) {
diff --git a/npm_assets/node_modules/luxon/src/luxon.js b/npm_assets/node_modules/luxon/src/luxon.js
index d391052..92a7225 100644
--- a/npm_assets/node_modules/luxon/src/luxon.js
+++ b/npm_assets/node_modules/luxon/src/luxon.js
@@ -6,10 +6,10 @@ import Zone from "./zone.js";
import FixedOffsetZone from "./zones/fixedOffsetZone.js";
import IANAZone from "./zones/IANAZone.js";
import InvalidZone from "./zones/invalidZone.js";
-import LocalZone from "./zones/localZone.js";
+import SystemZone from "./zones/systemZone.js";
import Settings from "./settings.js";
-const VERSION = "1.28.0";
+const VERSION = "3.3.0";
export {
VERSION,
@@ -21,6 +21,6 @@ export {
FixedOffsetZone,
IANAZone,
InvalidZone,
- LocalZone,
- Settings
+ SystemZone,
+ Settings,
};
diff --git a/npm_assets/node_modules/luxon/src/luxonFilled.js b/npm_assets/node_modules/luxon/src/luxonFilled.js
deleted file mode 100644
index 5145b18..0000000
--- a/npm_assets/node_modules/luxon/src/luxonFilled.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/* eslint import/no-extraneous-dependencies: off */
-
-import "core-js/features/symbol";
-import "core-js/features/symbol/iterator";
-import "core-js/features/object";
-import "core-js/features/number/is-nan";
-import "core-js/features/array";
-import "core-js/features/string/virtual/starts-with";
-import "core-js/features/string/virtual/repeat";
-import "core-js/features/math/trunc";
-import "core-js/features/math/sign";
-
-export * from "./luxon.js";
diff --git a/npm_assets/node_modules/luxon/src/package.json b/npm_assets/node_modules/luxon/src/package.json
new file mode 100644
index 0000000..58127b7
--- /dev/null
+++ b/npm_assets/node_modules/luxon/src/package.json
@@ -0,0 +1,4 @@
+{
+ "type": "module",
+ "version": "3.3.0"
+}
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}
*/
diff --git a/npm_assets/node_modules/luxon/src/zone.js b/npm_assets/node_modules/luxon/src/zone.js
index 8a5d070..cec0e4f 100644
--- a/npm_assets/node_modules/luxon/src/zone.js
+++ b/npm_assets/node_modules/luxon/src/zone.js
@@ -1,4 +1,3 @@
-/* eslint no-unused-vars: "off" */
import { ZoneIsAbstractError } from "./errors.js";
/**
@@ -23,12 +22,16 @@ export default class Zone {
throw new ZoneIsAbstractError();
}
+ get ianaName() {
+ return this.name;
+ }
+
/**
* Returns whether the offset is known to be fixed for the whole year.
* @abstract
* @type {boolean}
*/
- get universal() {
+ get isUniversal() {
throw new ZoneIsAbstractError();
}
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 **/