@nmshd/transport 2.0.5 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buildInformation.js +5 -5
- package/dist/core/CoreIdHelper.js.map +1 -1
- package/dist/core/backbone/RESTClient.js.map +1 -1
- package/dist/events/TransportDataEvent.js.map +1 -1
- package/dist/modules/sync/ChangedItems.js.map +1 -1
- package/dist/modules/sync/DatawalletModificationsProcessor.d.ts +6 -6
- package/dist/modules/sync/DatawalletModificationsProcessor.js +3 -3
- package/dist/modules/sync/DatawalletModificationsProcessor.js.map +1 -1
- package/dist/modules/sync/SyncController.js.map +1 -1
- package/lib-web/nmshd.transport.js +171 -90
- package/lib-web/nmshd.transport.js.map +1 -1
- package/lib-web/nmshd.transport.min.js +1 -1
- package/lib-web/nmshd.transport.min.js.map +1 -1
- package/package.json +12 -12
|
@@ -15,11 +15,11 @@ exports.buildInformation = void 0;
|
|
|
15
15
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
16
16
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
17
17
|
exports.buildInformation = {
|
|
18
|
-
version: "2.0.
|
|
19
|
-
build: "
|
|
20
|
-
date: "2023-
|
|
21
|
-
commit: "
|
|
22
|
-
dependencies: {"@js-soft/docdb-access-abstractions":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/simple-logger":"1.0.2","@js-soft/ts-utils":"2.3.1","axios":"^1.4.0","deep-equal":"^2.2.
|
|
18
|
+
version: "2.0.6",
|
|
19
|
+
build: "58",
|
|
20
|
+
date: "2023-08-16T10:31:10+00:00",
|
|
21
|
+
commit: "c4efb752148e149fd2793008702d9b719c09b0d1",
|
|
22
|
+
dependencies: {"@js-soft/docdb-access-abstractions":"1.0.1","@js-soft/logging-abstractions":"1.0.0","@js-soft/simple-logger":"1.0.2","@js-soft/ts-utils":"2.3.1","axios":"^1.4.0","deep-equal":"^2.2.2","fast-json-patch":"^3.1.1","form-data":"^4.0.0","json-stringify-safe":"^5.0.1","lodash":"^4.17.21","luxon":"^3.4.0","qs":"^6.11.2","reflect-metadata":"^0.1.13","ts-simple-nameof":"^1.3.1","uuid":"^9.0.0"},
|
|
23
23
|
libraries: {
|
|
24
24
|
crypto: crypto_1.buildInformation,
|
|
25
25
|
serval: ts_serval_1.buildInformation
|
|
@@ -10163,11 +10163,11 @@ const core_1 = __webpack_require__(/*! ../../core */ "./dist/core/index.js");
|
|
|
10163
10163
|
const DbCollectionName_1 = __webpack_require__(/*! ../../core/DbCollectionName */ "./dist/core/DbCollectionName.js");
|
|
10164
10164
|
const File_1 = __webpack_require__(/*! ../files/local/File */ "./dist/modules/files/local/File.js");
|
|
10165
10165
|
const Message_1 = __webpack_require__(/*! ../messages/local/Message */ "./dist/modules/messages/local/Message.js");
|
|
10166
|
-
const Relationship_1 = __webpack_require__(/*! ../relationships/local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
|
|
10167
10166
|
const RelationshipTemplate_1 = __webpack_require__(/*! ../relationshipTemplates/local/RelationshipTemplate */ "./dist/modules/relationshipTemplates/local/RelationshipTemplate.js");
|
|
10167
|
+
const Relationship_1 = __webpack_require__(/*! ../relationships/local/Relationship */ "./dist/modules/relationships/local/Relationship.js");
|
|
10168
10168
|
const Token_1 = __webpack_require__(/*! ../tokens/local/Token */ "./dist/modules/tokens/local/Token.js");
|
|
10169
|
-
const DatawalletModification_1 = __webpack_require__(/*! ./local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
|
|
10170
10169
|
const SyncCallback_1 = __webpack_require__(/*! ./SyncCallback */ "./dist/modules/sync/SyncCallback.js");
|
|
10170
|
+
const DatawalletModification_1 = __webpack_require__(/*! ./local/DatawalletModification */ "./dist/modules/sync/local/DatawalletModification.js");
|
|
10171
10171
|
class DatawalletModificationsProcessor {
|
|
10172
10172
|
get log() {
|
|
10173
10173
|
return this.logger;
|
|
@@ -10320,7 +10320,7 @@ class DatawalletModificationsProcessor {
|
|
|
10320
10320
|
}
|
|
10321
10321
|
for (const deleteModification of this.deletes) {
|
|
10322
10322
|
const targetCollection = await this.collectionProvider.getCollection(deleteModification.collection);
|
|
10323
|
-
await targetCollection.delete({ id: deleteModification.objectIdentifier });
|
|
10323
|
+
await targetCollection.delete({ id: deleteModification.objectIdentifier.toString() });
|
|
10324
10324
|
this.syncStep.progress();
|
|
10325
10325
|
}
|
|
10326
10326
|
}
|
|
@@ -33330,7 +33330,7 @@ function intlConfigString(localeStr, numberingSystem, outputCalendar) {
|
|
|
33330
33330
|
function mapMonths(f) {
|
|
33331
33331
|
const ms = [];
|
|
33332
33332
|
for (let i = 1; i <= 12; i++) {
|
|
33333
|
-
const dt = DateTime.utc(
|
|
33333
|
+
const dt = DateTime.utc(2009, i, 1);
|
|
33334
33334
|
ms.push(f(dt));
|
|
33335
33335
|
}
|
|
33336
33336
|
return ms;
|
|
@@ -33343,8 +33343,8 @@ function mapWeekdays(f) {
|
|
|
33343
33343
|
}
|
|
33344
33344
|
return ms;
|
|
33345
33345
|
}
|
|
33346
|
-
function listStuff(loc, length,
|
|
33347
|
-
const mode = loc.listingMode(
|
|
33346
|
+
function listStuff(loc, length, englishFn, intlFn) {
|
|
33347
|
+
const mode = loc.listingMode();
|
|
33348
33348
|
if (mode === "error") {
|
|
33349
33349
|
return null;
|
|
33350
33350
|
} else if (mode === "en") {
|
|
@@ -33590,8 +33590,8 @@ class Locale {
|
|
|
33590
33590
|
defaultToEN: false
|
|
33591
33591
|
});
|
|
33592
33592
|
}
|
|
33593
|
-
months(length, format = false
|
|
33594
|
-
return listStuff(this, length,
|
|
33593
|
+
months(length, format = false) {
|
|
33594
|
+
return listStuff(this, length, months, () => {
|
|
33595
33595
|
const intl = format ? {
|
|
33596
33596
|
month: length,
|
|
33597
33597
|
day: "numeric"
|
|
@@ -33605,8 +33605,8 @@ class Locale {
|
|
|
33605
33605
|
return this.monthsCache[formatStr][length];
|
|
33606
33606
|
});
|
|
33607
33607
|
}
|
|
33608
|
-
weekdays(length, format = false
|
|
33609
|
-
return listStuff(this, length,
|
|
33608
|
+
weekdays(length, format = false) {
|
|
33609
|
+
return listStuff(this, length, weekdays, () => {
|
|
33610
33610
|
const intl = format ? {
|
|
33611
33611
|
weekday: length,
|
|
33612
33612
|
year: "numeric",
|
|
@@ -33622,8 +33622,8 @@ class Locale {
|
|
|
33622
33622
|
return this.weekdaysCache[formatStr][length];
|
|
33623
33623
|
});
|
|
33624
33624
|
}
|
|
33625
|
-
meridiems(
|
|
33626
|
-
return listStuff(this, undefined,
|
|
33625
|
+
meridiems() {
|
|
33626
|
+
return listStuff(this, undefined, () => meridiems, () => {
|
|
33627
33627
|
// In theory there could be aribitrary day periods. We're gonna assume there are exactly two
|
|
33628
33628
|
// for AM and PM. This is probably wrong, but it's makes parsing way easier.
|
|
33629
33629
|
if (!this.meridiemCache) {
|
|
@@ -33636,8 +33636,8 @@ class Locale {
|
|
|
33636
33636
|
return this.meridiemCache;
|
|
33637
33637
|
});
|
|
33638
33638
|
}
|
|
33639
|
-
eras(length
|
|
33640
|
-
return listStuff(this, length,
|
|
33639
|
+
eras(length) {
|
|
33640
|
+
return listStuff(this, length, eras, () => {
|
|
33641
33641
|
const intl = {
|
|
33642
33642
|
era: length
|
|
33643
33643
|
};
|
|
@@ -33841,7 +33841,7 @@ function normalizeZone(input, defaultZone) {
|
|
|
33841
33841
|
if (lowered === "default") return defaultZone;else if (lowered === "local" || lowered === "system") return SystemZone.instance;else if (lowered === "utc" || lowered === "gmt") return FixedOffsetZone.utcInstance;else return FixedOffsetZone.parseSpecifier(lowered) || IANAZone.create(input);
|
|
33842
33842
|
} else if (isNumber(input)) {
|
|
33843
33843
|
return FixedOffsetZone.instance(input);
|
|
33844
|
-
} else if (typeof input === "object" &&
|
|
33844
|
+
} else if (typeof input === "object" && "offset" in input && typeof input.offset === "function") {
|
|
33845
33845
|
// This is dumb, but the instanceof check above doesn't seem to really work
|
|
33846
33846
|
// so we're duck checking it
|
|
33847
33847
|
return input;
|
|
@@ -33958,10 +33958,10 @@ class Settings {
|
|
|
33958
33958
|
/**
|
|
33959
33959
|
* Set the cutoff year after which a string encoding a year as two digits is interpreted to occur in the current century.
|
|
33960
33960
|
* @type {number}
|
|
33961
|
-
* @example Settings.twoDigitCutoffYear = 0 // cut-off year is 0, so all 'yy' are
|
|
33961
|
+
* @example Settings.twoDigitCutoffYear = 0 // cut-off year is 0, so all 'yy' are interpreted as current century
|
|
33962
33962
|
* @example Settings.twoDigitCutoffYear = 50 // '49' -> 1949; '50' -> 2050
|
|
33963
|
-
* @example Settings.twoDigitCutoffYear = 1950 //
|
|
33964
|
-
* @example Settings.twoDigitCutoffYear = 2050 // ALSO
|
|
33963
|
+
* @example Settings.twoDigitCutoffYear = 1950 // interpreted as 50
|
|
33964
|
+
* @example Settings.twoDigitCutoffYear = 2050 // ALSO interpreted as 50
|
|
33965
33965
|
*/
|
|
33966
33966
|
static set twoDigitCutoffYear(cutoffYear) {
|
|
33967
33967
|
twoDigitCutoffYear = cutoffYear % 100;
|
|
@@ -34128,7 +34128,7 @@ function daysInMonth(year, month) {
|
|
|
34128
34128
|
}
|
|
34129
34129
|
}
|
|
34130
34130
|
|
|
34131
|
-
//
|
|
34131
|
+
// convert a calendar object to a local timestamp (epoch, but with the offset baked in)
|
|
34132
34132
|
function objToLocalTS(obj) {
|
|
34133
34133
|
let d = Date.UTC(obj.year, obj.month - 1, obj.day, obj.hour, obj.minute, obj.second, obj.millisecond);
|
|
34134
34134
|
|
|
@@ -34430,33 +34430,24 @@ class Formatter {
|
|
|
34430
34430
|
});
|
|
34431
34431
|
return df.format();
|
|
34432
34432
|
}
|
|
34433
|
-
|
|
34434
|
-
|
|
34433
|
+
dtFormatter(dt, opts = {}) {
|
|
34434
|
+
return this.loc.dtFormatter(dt, {
|
|
34435
34435
|
...this.opts,
|
|
34436
34436
|
...opts
|
|
34437
34437
|
});
|
|
34438
|
-
return df.format();
|
|
34439
34438
|
}
|
|
34440
|
-
|
|
34441
|
-
|
|
34442
|
-
...this.opts,
|
|
34443
|
-
...opts
|
|
34444
|
-
});
|
|
34445
|
-
return df.formatToParts();
|
|
34439
|
+
formatDateTime(dt, opts) {
|
|
34440
|
+
return this.dtFormatter(dt, opts).format();
|
|
34446
34441
|
}
|
|
34447
|
-
|
|
34448
|
-
|
|
34449
|
-
|
|
34450
|
-
|
|
34451
|
-
|
|
34442
|
+
formatDateTimeParts(dt, opts) {
|
|
34443
|
+
return this.dtFormatter(dt, opts).formatToParts();
|
|
34444
|
+
}
|
|
34445
|
+
formatInterval(interval, opts) {
|
|
34446
|
+
const df = this.dtFormatter(interval.start, opts);
|
|
34452
34447
|
return df.dtf.formatRange(interval.start.toJSDate(), interval.end.toJSDate());
|
|
34453
34448
|
}
|
|
34454
|
-
resolvedOptions(dt, opts
|
|
34455
|
-
|
|
34456
|
-
...this.opts,
|
|
34457
|
-
...opts
|
|
34458
|
-
});
|
|
34459
|
-
return df.resolvedOptions();
|
|
34449
|
+
resolvedOptions(dt, opts) {
|
|
34450
|
+
return this.dtFormatter(dt, opts).resolvedOptions();
|
|
34460
34451
|
}
|
|
34461
34452
|
num(n, p = 0) {
|
|
34462
34453
|
// we get some perf out of doing this here, annoyingly
|
|
@@ -34510,7 +34501,7 @@ class Formatter {
|
|
|
34510
34501
|
era: length
|
|
34511
34502
|
}, "era"),
|
|
34512
34503
|
tokenToString = token => {
|
|
34513
|
-
// Where possible:
|
|
34504
|
+
// Where possible: https://cldr.unicode.org/translation/date-time/date-time-symbols
|
|
34514
34505
|
switch (token) {
|
|
34515
34506
|
// ms
|
|
34516
34507
|
case "S":
|
|
@@ -35099,19 +35090,19 @@ function clone$1(dur, alts, clear = false) {
|
|
|
35099
35090
|
};
|
|
35100
35091
|
return new Duration(conf);
|
|
35101
35092
|
}
|
|
35102
|
-
|
|
35103
|
-
|
|
35093
|
+
|
|
35094
|
+
// this is needed since in some test cases it would return 0.9999999999999999 instead of 1
|
|
35095
|
+
function removePrecisionIssue(a) {
|
|
35096
|
+
return Math.trunc(a * 1e3) / 1e3;
|
|
35104
35097
|
}
|
|
35105
35098
|
|
|
35106
35099
|
// NB: mutates parameters
|
|
35107
35100
|
function convert(matrix, fromMap, fromUnit, toMap, toUnit) {
|
|
35108
35101
|
const conv = matrix[toUnit][fromUnit],
|
|
35109
35102
|
raw = fromMap[fromUnit] / conv,
|
|
35110
|
-
|
|
35111
|
-
|
|
35112
|
-
|
|
35113
|
-
toMap[toUnit] += added;
|
|
35114
|
-
fromMap[fromUnit] -= added * conv;
|
|
35103
|
+
added = Math.floor(raw);
|
|
35104
|
+
toMap[toUnit] = removePrecisionIssue(toMap[toUnit] + added);
|
|
35105
|
+
fromMap[fromUnit] = removePrecisionIssue(fromMap[fromUnit] - added * conv);
|
|
35115
35106
|
}
|
|
35116
35107
|
|
|
35117
35108
|
// NB: mutates parameters
|
|
@@ -35510,21 +35501,13 @@ class Duration {
|
|
|
35510
35501
|
suppressSeconds: false,
|
|
35511
35502
|
includePrefix: false,
|
|
35512
35503
|
format: "extended",
|
|
35513
|
-
...opts
|
|
35504
|
+
...opts,
|
|
35505
|
+
includeOffset: false
|
|
35514
35506
|
};
|
|
35515
|
-
const
|
|
35516
|
-
|
|
35517
|
-
|
|
35518
|
-
|
|
35519
|
-
if (!opts.suppressMilliseconds || value.milliseconds !== 0) {
|
|
35520
|
-
fmt += ".SSS";
|
|
35521
|
-
}
|
|
35522
|
-
}
|
|
35523
|
-
let str = value.toFormat(fmt);
|
|
35524
|
-
if (opts.includePrefix) {
|
|
35525
|
-
str = "T" + str;
|
|
35526
|
-
}
|
|
35527
|
-
return str;
|
|
35507
|
+
const dateTime = DateTime.fromMillis(millis, {
|
|
35508
|
+
zone: "UTC"
|
|
35509
|
+
});
|
|
35510
|
+
return dateTime.toISOTime(opts);
|
|
35528
35511
|
}
|
|
35529
35512
|
|
|
35530
35513
|
/**
|
|
@@ -35548,7 +35531,15 @@ class Duration {
|
|
|
35548
35531
|
* @return {number}
|
|
35549
35532
|
*/
|
|
35550
35533
|
toMillis() {
|
|
35551
|
-
|
|
35534
|
+
var _this$values$millisec;
|
|
35535
|
+
let sum = (_this$values$millisec = this.values.milliseconds) != null ? _this$values$millisec : 0;
|
|
35536
|
+
for (let unit of reverseUnits.slice(1)) {
|
|
35537
|
+
var _this$values;
|
|
35538
|
+
if ((_this$values = this.values) != null && _this$values[unit]) {
|
|
35539
|
+
sum += this.values[unit] * this.matrix[unit]["milliseconds"];
|
|
35540
|
+
}
|
|
35541
|
+
}
|
|
35542
|
+
return sum;
|
|
35552
35543
|
}
|
|
35553
35544
|
|
|
35554
35545
|
/**
|
|
@@ -35681,10 +35672,13 @@ class Duration {
|
|
|
35681
35672
|
normalize() {
|
|
35682
35673
|
if (!this.isValid) return this;
|
|
35683
35674
|
const vals = this.toObject();
|
|
35684
|
-
|
|
35685
|
-
|
|
35686
|
-
|
|
35687
|
-
|
|
35675
|
+
if (this.valueOf() >= 0) {
|
|
35676
|
+
normalizeValues(this.matrix, vals);
|
|
35677
|
+
return clone$1(this, {
|
|
35678
|
+
values: vals
|
|
35679
|
+
}, true);
|
|
35680
|
+
}
|
|
35681
|
+
return this.negate().normalize().negate();
|
|
35688
35682
|
}
|
|
35689
35683
|
|
|
35690
35684
|
/**
|
|
@@ -36713,14 +36707,35 @@ function highOrderDiffs(cursor, later, units) {
|
|
|
36713
36707
|
const results = {};
|
|
36714
36708
|
const earlier = cursor;
|
|
36715
36709
|
let lowestOrder, highWater;
|
|
36710
|
+
|
|
36711
|
+
/* This loop tries to diff using larger units first.
|
|
36712
|
+
If we overshoot, we backtrack and try the next smaller unit.
|
|
36713
|
+
"cursor" starts out at the earlier timestamp and moves closer and closer to "later"
|
|
36714
|
+
as we use smaller and smaller units.
|
|
36715
|
+
highWater keeps track of where we would be if we added one more of the smallest unit,
|
|
36716
|
+
this is used later to potentially convert any difference smaller than the smallest higher order unit
|
|
36717
|
+
into a fraction of that smallest higher order unit
|
|
36718
|
+
*/
|
|
36716
36719
|
for (const [unit, differ] of differs) {
|
|
36717
36720
|
if (units.indexOf(unit) >= 0) {
|
|
36718
36721
|
lowestOrder = unit;
|
|
36719
36722
|
results[unit] = differ(cursor, later);
|
|
36720
36723
|
highWater = earlier.plus(results);
|
|
36721
36724
|
if (highWater > later) {
|
|
36725
|
+
// we overshot the end point, backtrack cursor by 1
|
|
36722
36726
|
results[unit]--;
|
|
36723
36727
|
cursor = earlier.plus(results);
|
|
36728
|
+
|
|
36729
|
+
// if we are still overshooting now, we need to backtrack again
|
|
36730
|
+
// this happens in certain situations when diffing times in different zones,
|
|
36731
|
+
// because this calculation ignores time zones
|
|
36732
|
+
if (cursor > later) {
|
|
36733
|
+
// keep the "overshot by 1" around as highWater
|
|
36734
|
+
highWater = cursor;
|
|
36735
|
+
// backtrack cursor by 1
|
|
36736
|
+
results[unit]--;
|
|
36737
|
+
cursor = earlier.plus(results);
|
|
36738
|
+
}
|
|
36724
36739
|
} else {
|
|
36725
36740
|
cursor = highWater;
|
|
36726
36741
|
}
|
|
@@ -36869,6 +36884,11 @@ function simple(regex) {
|
|
|
36869
36884
|
function escapeToken(value) {
|
|
36870
36885
|
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
36871
36886
|
}
|
|
36887
|
+
|
|
36888
|
+
/**
|
|
36889
|
+
* @param token
|
|
36890
|
+
* @param {Locale} loc
|
|
36891
|
+
*/
|
|
36872
36892
|
function unitForToken(token, loc) {
|
|
36873
36893
|
const one = digitRegex(loc),
|
|
36874
36894
|
two = digitRegex(loc, "{2}"),
|
|
@@ -36893,9 +36913,9 @@ function unitForToken(token, loc) {
|
|
|
36893
36913
|
switch (t.val) {
|
|
36894
36914
|
// era
|
|
36895
36915
|
case "G":
|
|
36896
|
-
return oneOf(loc.eras("short"
|
|
36916
|
+
return oneOf(loc.eras("short"), 0);
|
|
36897
36917
|
case "GG":
|
|
36898
|
-
return oneOf(loc.eras("long"
|
|
36918
|
+
return oneOf(loc.eras("long"), 0);
|
|
36899
36919
|
// years
|
|
36900
36920
|
case "y":
|
|
36901
36921
|
return intUnit(oneToSix);
|
|
@@ -36913,17 +36933,17 @@ function unitForToken(token, loc) {
|
|
|
36913
36933
|
case "MM":
|
|
36914
36934
|
return intUnit(two);
|
|
36915
36935
|
case "MMM":
|
|
36916
|
-
return oneOf(loc.months("short", true
|
|
36936
|
+
return oneOf(loc.months("short", true), 1);
|
|
36917
36937
|
case "MMMM":
|
|
36918
|
-
return oneOf(loc.months("long", true
|
|
36938
|
+
return oneOf(loc.months("long", true), 1);
|
|
36919
36939
|
case "L":
|
|
36920
36940
|
return intUnit(oneOrTwo);
|
|
36921
36941
|
case "LL":
|
|
36922
36942
|
return intUnit(two);
|
|
36923
36943
|
case "LLL":
|
|
36924
|
-
return oneOf(loc.months("short", false
|
|
36944
|
+
return oneOf(loc.months("short", false), 1);
|
|
36925
36945
|
case "LLLL":
|
|
36926
|
-
return oneOf(loc.months("long", false
|
|
36946
|
+
return oneOf(loc.months("long", false), 1);
|
|
36927
36947
|
// dates
|
|
36928
36948
|
case "d":
|
|
36929
36949
|
return intUnit(oneOrTwo);
|
|
@@ -36983,13 +37003,13 @@ function unitForToken(token, loc) {
|
|
|
36983
37003
|
case "c":
|
|
36984
37004
|
return intUnit(one);
|
|
36985
37005
|
case "EEE":
|
|
36986
|
-
return oneOf(loc.weekdays("short", false
|
|
37006
|
+
return oneOf(loc.weekdays("short", false), 1);
|
|
36987
37007
|
case "EEEE":
|
|
36988
|
-
return oneOf(loc.weekdays("long", false
|
|
37008
|
+
return oneOf(loc.weekdays("long", false), 1);
|
|
36989
37009
|
case "ccc":
|
|
36990
|
-
return oneOf(loc.weekdays("short", true
|
|
37010
|
+
return oneOf(loc.weekdays("short", true), 1);
|
|
36991
37011
|
case "cccc":
|
|
36992
|
-
return oneOf(loc.weekdays("long", true
|
|
37012
|
+
return oneOf(loc.weekdays("long", true), 1);
|
|
36993
37013
|
// offset/zone
|
|
36994
37014
|
case "Z":
|
|
36995
37015
|
case "ZZ":
|
|
@@ -37035,10 +37055,14 @@ const partTypeStyleToTokenVal = {
|
|
|
37035
37055
|
},
|
|
37036
37056
|
dayperiod: "a",
|
|
37037
37057
|
dayPeriod: "a",
|
|
37038
|
-
|
|
37058
|
+
hour12: {
|
|
37039
37059
|
numeric: "h",
|
|
37040
37060
|
"2-digit": "hh"
|
|
37041
37061
|
},
|
|
37062
|
+
hour24: {
|
|
37063
|
+
numeric: "H",
|
|
37064
|
+
"2-digit": "HH"
|
|
37065
|
+
},
|
|
37042
37066
|
minute: {
|
|
37043
37067
|
numeric: "m",
|
|
37044
37068
|
"2-digit": "mm"
|
|
@@ -37052,7 +37076,7 @@ const partTypeStyleToTokenVal = {
|
|
|
37052
37076
|
short: "ZZZ"
|
|
37053
37077
|
}
|
|
37054
37078
|
};
|
|
37055
|
-
function tokenForPart(part, formatOpts) {
|
|
37079
|
+
function tokenForPart(part, formatOpts, resolvedOpts) {
|
|
37056
37080
|
const {
|
|
37057
37081
|
type,
|
|
37058
37082
|
value
|
|
@@ -37065,7 +37089,27 @@ function tokenForPart(part, formatOpts) {
|
|
|
37065
37089
|
};
|
|
37066
37090
|
}
|
|
37067
37091
|
const style = formatOpts[type];
|
|
37068
|
-
|
|
37092
|
+
|
|
37093
|
+
// The user might have explicitly specified hour12 or hourCycle
|
|
37094
|
+
// if so, respect their decision
|
|
37095
|
+
// if not, refer back to the resolvedOpts, which are based on the locale
|
|
37096
|
+
let actualType = type;
|
|
37097
|
+
if (type === "hour") {
|
|
37098
|
+
if (formatOpts.hour12 != null) {
|
|
37099
|
+
actualType = formatOpts.hour12 ? "hour12" : "hour24";
|
|
37100
|
+
} else if (formatOpts.hourCycle != null) {
|
|
37101
|
+
if (formatOpts.hourCycle === "h11" || formatOpts.hourCycle === "h12") {
|
|
37102
|
+
actualType = "hour12";
|
|
37103
|
+
} else {
|
|
37104
|
+
actualType = "hour24";
|
|
37105
|
+
}
|
|
37106
|
+
} else {
|
|
37107
|
+
// tokens only differentiate between 24 hours or not,
|
|
37108
|
+
// so we do not need to check hourCycle here, which is less supported anyways
|
|
37109
|
+
actualType = resolvedOpts.hour12 ? "hour12" : "hour24";
|
|
37110
|
+
}
|
|
37111
|
+
}
|
|
37112
|
+
let val = partTypeStyleToTokenVal[actualType];
|
|
37069
37113
|
if (typeof val === "object") {
|
|
37070
37114
|
val = val[style];
|
|
37071
37115
|
}
|
|
@@ -37241,8 +37285,10 @@ function formatOptsToTokens(formatOpts, locale) {
|
|
|
37241
37285
|
return null;
|
|
37242
37286
|
}
|
|
37243
37287
|
const formatter = Formatter.create(locale, formatOpts);
|
|
37244
|
-
const
|
|
37245
|
-
|
|
37288
|
+
const df = formatter.dtFormatter(getDummyDateTime());
|
|
37289
|
+
const parts = df.formatToParts();
|
|
37290
|
+
const resolvedOpts = df.resolvedOptions();
|
|
37291
|
+
return parts.map(p => tokenForPart(p, formatOpts, resolvedOpts));
|
|
37246
37292
|
}
|
|
37247
37293
|
|
|
37248
37294
|
const nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
|
|
@@ -37578,13 +37624,13 @@ function toISOTime(o, extended, suppressSeconds, suppressMilliseconds, includeOf
|
|
|
37578
37624
|
if (extended) {
|
|
37579
37625
|
c += ":";
|
|
37580
37626
|
c += padStart(o.c.minute);
|
|
37581
|
-
if (o.c.second !== 0 || !suppressSeconds) {
|
|
37627
|
+
if (o.c.millisecond !== 0 || o.c.second !== 0 || !suppressSeconds) {
|
|
37582
37628
|
c += ":";
|
|
37583
37629
|
}
|
|
37584
37630
|
} else {
|
|
37585
37631
|
c += padStart(o.c.minute);
|
|
37586
37632
|
}
|
|
37587
|
-
if (o.c.second !== 0 || !suppressSeconds) {
|
|
37633
|
+
if (o.c.millisecond !== 0 || o.c.second !== 0 || !suppressSeconds) {
|
|
37588
37634
|
c += padStart(o.c.second);
|
|
37589
37635
|
if (o.c.millisecond !== 0 || !suppressMilliseconds) {
|
|
37590
37636
|
c += ".";
|
|
@@ -38218,7 +38264,7 @@ class DateTime {
|
|
|
38218
38264
|
|
|
38219
38265
|
/**
|
|
38220
38266
|
* Create an invalid DateTime.
|
|
38221
|
-
* @param {
|
|
38267
|
+
* @param {string} reason - simple string of why this DateTime is invalid. Should not contain parameters or anything else data-dependent.
|
|
38222
38268
|
* @param {string} [explanation=null] - longer explanation, may include parameters and other useful debugging information
|
|
38223
38269
|
* @return {DateTime}
|
|
38224
38270
|
*/
|
|
@@ -38577,6 +38623,41 @@ class DateTime {
|
|
|
38577
38623
|
}
|
|
38578
38624
|
}
|
|
38579
38625
|
|
|
38626
|
+
/**
|
|
38627
|
+
* Get those DateTimes which have the same local time as this DateTime, but a different offset from UTC
|
|
38628
|
+
* in this DateTime's zone. During DST changes local time can be ambiguous, for example
|
|
38629
|
+
* `2023-10-29T02:30:00` in `Europe/Berlin` can have offset `+01:00` or `+02:00`.
|
|
38630
|
+
* This method will return both possible DateTimes if this DateTime's local time is ambiguous.
|
|
38631
|
+
* @returns {DateTime[]}
|
|
38632
|
+
*/
|
|
38633
|
+
getPossibleOffsets() {
|
|
38634
|
+
if (!this.isValid || this.isOffsetFixed) {
|
|
38635
|
+
return [this];
|
|
38636
|
+
}
|
|
38637
|
+
const dayMs = 86400000;
|
|
38638
|
+
const minuteMs = 60000;
|
|
38639
|
+
const localTS = objToLocalTS(this.c);
|
|
38640
|
+
const oEarlier = this.zone.offset(localTS - dayMs);
|
|
38641
|
+
const oLater = this.zone.offset(localTS + dayMs);
|
|
38642
|
+
const o1 = this.zone.offset(localTS - oEarlier * minuteMs);
|
|
38643
|
+
const o2 = this.zone.offset(localTS - oLater * minuteMs);
|
|
38644
|
+
if (o1 === o2) {
|
|
38645
|
+
return [this];
|
|
38646
|
+
}
|
|
38647
|
+
const ts1 = localTS - o1 * minuteMs;
|
|
38648
|
+
const ts2 = localTS - o2 * minuteMs;
|
|
38649
|
+
const c1 = tsToObj(ts1, o1);
|
|
38650
|
+
const c2 = tsToObj(ts2, o2);
|
|
38651
|
+
if (c1.hour === c2.hour && c1.minute === c2.minute && c1.second === c2.second && c1.millisecond === c2.millisecond) {
|
|
38652
|
+
return [clone(this, {
|
|
38653
|
+
ts: ts1
|
|
38654
|
+
}), clone(this, {
|
|
38655
|
+
ts: ts2
|
|
38656
|
+
})];
|
|
38657
|
+
}
|
|
38658
|
+
return [this];
|
|
38659
|
+
}
|
|
38660
|
+
|
|
38580
38661
|
/**
|
|
38581
38662
|
* Returns true if this DateTime is in a leap year, false otherwise
|
|
38582
38663
|
* @example DateTime.local(2016).isInLeapYear //=> true
|
|
@@ -39583,7 +39664,7 @@ function friendlyDateTime(dateTimeish) {
|
|
|
39583
39664
|
}
|
|
39584
39665
|
}
|
|
39585
39666
|
|
|
39586
|
-
const VERSION = "3.
|
|
39667
|
+
const VERSION = "3.4.0";
|
|
39587
39668
|
|
|
39588
39669
|
exports.DateTime = DateTime;
|
|
39589
39670
|
exports.Duration = Duration;
|