@digipair/skill-cron 0.42.0 → 0.43.3
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs.js +464 -190
- package/index.esm.js +464 -190
- package/package.json +1 -1
package/index.cjs.js
CHANGED
@@ -561,7 +561,12 @@ var DATETIME_HUGE_WITH_SECONDS = {
|
|
561
561
|
},
|
562
562
|
{
|
563
563
|
key: "ianaName",
|
564
|
-
get:
|
564
|
+
get: /**
|
565
|
+
* The IANA name of this zone.
|
566
|
+
* Defaults to `name` if not overwritten by a subclass.
|
567
|
+
* @abstract
|
568
|
+
* @type {string}
|
569
|
+
*/ function get() {
|
565
570
|
return this.name;
|
566
571
|
}
|
567
572
|
},
|
@@ -784,37 +789,70 @@ var ianaZoneCache = {};
|
|
784
789
|
_create_class$2(IANAZone, [
|
785
790
|
{
|
786
791
|
key: "type",
|
787
|
-
get: /**
|
792
|
+
get: /**
|
793
|
+
* The type of zone. `iana` for all instances of `IANAZone`.
|
794
|
+
* @override
|
795
|
+
* @type {string}
|
796
|
+
*/ function get() {
|
788
797
|
return "iana";
|
789
798
|
}
|
790
799
|
},
|
791
800
|
{
|
792
801
|
key: "name",
|
793
|
-
get: /**
|
802
|
+
get: /**
|
803
|
+
* The name of this zone (i.e. the IANA zone name).
|
804
|
+
* @override
|
805
|
+
* @type {string}
|
806
|
+
*/ function get() {
|
794
807
|
return this.zoneName;
|
795
808
|
}
|
796
809
|
},
|
797
810
|
{
|
798
811
|
key: "isUniversal",
|
799
|
-
get: /**
|
812
|
+
get: /**
|
813
|
+
* Returns whether the offset is known to be fixed for the whole year:
|
814
|
+
* Always returns false for all IANA zones.
|
815
|
+
* @override
|
816
|
+
* @type {boolean}
|
817
|
+
*/ function get() {
|
800
818
|
return false;
|
801
819
|
}
|
802
820
|
},
|
803
821
|
{
|
804
|
-
/**
|
822
|
+
/**
|
823
|
+
* Returns the offset's common name (such as EST) at the specified timestamp
|
824
|
+
* @override
|
825
|
+
* @param {number} ts - Epoch milliseconds for which to get the name
|
826
|
+
* @param {Object} opts - Options to affect the format
|
827
|
+
* @param {string} opts.format - What style of offset to return. Accepts 'long' or 'short'.
|
828
|
+
* @param {string} opts.locale - What locale to return the offset name in.
|
829
|
+
* @return {string}
|
830
|
+
*/ key: "offsetName",
|
805
831
|
value: function offsetName(ts, param) {
|
806
832
|
var format = param.format, locale = param.locale;
|
807
833
|
return parseZoneInfo(ts, format, locale, this.name);
|
808
834
|
}
|
809
835
|
},
|
810
836
|
{
|
811
|
-
/**
|
837
|
+
/**
|
838
|
+
* Returns the offset's value as a string
|
839
|
+
* @override
|
840
|
+
* @param {number} ts - Epoch milliseconds for which to get the offset
|
841
|
+
* @param {string} format - What style of offset to return.
|
842
|
+
* Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
843
|
+
* @return {string}
|
844
|
+
*/ key: "formatOffset",
|
812
845
|
value: function formatOffset1(ts, format) {
|
813
846
|
return formatOffset(this.offset(ts), format);
|
814
847
|
}
|
815
848
|
},
|
816
849
|
{
|
817
|
-
/**
|
850
|
+
/**
|
851
|
+
* Return the offset in minutes for this zone at the specified timestamp.
|
852
|
+
* @override
|
853
|
+
* @param {number} ts - Epoch milliseconds for which to compute the offset
|
854
|
+
* @return {number}
|
855
|
+
*/ key: "offset",
|
818
856
|
value: function offset(ts) {
|
819
857
|
var date = new Date(ts);
|
820
858
|
if (isNaN(date)) return NaN;
|
@@ -841,14 +879,23 @@ var ianaZoneCache = {};
|
|
841
879
|
}
|
842
880
|
},
|
843
881
|
{
|
844
|
-
/**
|
882
|
+
/**
|
883
|
+
* Return whether this Zone is equal to another zone
|
884
|
+
* @override
|
885
|
+
* @param {Zone} otherZone - the zone to compare
|
886
|
+
* @return {boolean}
|
887
|
+
*/ key: "equals",
|
845
888
|
value: function equals(otherZone) {
|
846
889
|
return otherZone.type === "iana" && otherZone.name === this.name;
|
847
890
|
}
|
848
891
|
},
|
849
892
|
{
|
850
893
|
key: "isValid",
|
851
|
-
get: /**
|
894
|
+
get: /**
|
895
|
+
* Return whether this Zone is valid.
|
896
|
+
* @override
|
897
|
+
* @type {boolean}
|
898
|
+
*/ function get() {
|
852
899
|
return this.valid;
|
853
900
|
}
|
854
901
|
}
|
@@ -882,7 +929,7 @@ var ianaZoneCache = {};
|
|
882
929
|
* @param {string} s - The string to check validity on
|
883
930
|
* @example IANAZone.isValidSpecifier("America/New_York") //=> true
|
884
931
|
* @example IANAZone.isValidSpecifier("Sport~~blorp") //=> false
|
885
|
-
* @deprecated
|
932
|
+
* @deprecated For backward compatibility, this forwards to isValidZone, better use `isValidZone()` directly instead.
|
886
933
|
* @return {boolean}
|
887
934
|
*/ function isValidSpecifier(s) {
|
888
935
|
return this.isValidZone(s);
|
@@ -1499,6 +1546,12 @@ var fallbackWeekSettings = {
|
|
1499
1546
|
value: function equals(other) {
|
1500
1547
|
return this.locale === other.locale && this.numberingSystem === other.numberingSystem && this.outputCalendar === other.outputCalendar;
|
1501
1548
|
}
|
1549
|
+
},
|
1550
|
+
{
|
1551
|
+
key: "toString",
|
1552
|
+
value: function toString() {
|
1553
|
+
return "Locale(".concat(this.locale, ", ").concat(this.numberingSystem, ", ").concat(this.outputCalendar, ")");
|
1554
|
+
}
|
1502
1555
|
}
|
1503
1556
|
], [
|
1504
1557
|
{
|
@@ -1512,7 +1565,7 @@ var fallbackWeekSettings = {
|
|
1512
1565
|
value: function create(locale, numberingSystem, outputCalendar, weekSettings) {
|
1513
1566
|
var defaultToEN = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
|
1514
1567
|
var specifiedLocale = locale || Settings.defaultLocale;
|
1515
|
-
// the system locale is useful for human
|
1568
|
+
// the system locale is useful for human-readable strings but annoying for parsing/formatting known formats
|
1516
1569
|
var localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale());
|
1517
1570
|
var numberingSystemR = numberingSystem || Settings.defaultNumberingSystem;
|
1518
1571
|
var outputCalendarR = outputCalendar || Settings.defaultOutputCalendar;
|
@@ -1556,19 +1609,33 @@ var singleton = null;
|
|
1556
1609
|
_create_class$2(FixedOffsetZone, [
|
1557
1610
|
{
|
1558
1611
|
key: "type",
|
1559
|
-
get: /**
|
1612
|
+
get: /**
|
1613
|
+
* The type of zone. `fixed` for all instances of `FixedOffsetZone`.
|
1614
|
+
* @override
|
1615
|
+
* @type {string}
|
1616
|
+
*/ function get() {
|
1560
1617
|
return "fixed";
|
1561
1618
|
}
|
1562
1619
|
},
|
1563
1620
|
{
|
1564
1621
|
key: "name",
|
1565
|
-
get: /**
|
1622
|
+
get: /**
|
1623
|
+
* The name of this zone.
|
1624
|
+
* All fixed zones' names always start with "UTC" (plus optional offset)
|
1625
|
+
* @override
|
1626
|
+
* @type {string}
|
1627
|
+
*/ function get() {
|
1566
1628
|
return this.fixed === 0 ? "UTC" : "UTC".concat(formatOffset(this.fixed, "narrow"));
|
1567
1629
|
}
|
1568
1630
|
},
|
1569
1631
|
{
|
1570
1632
|
key: "ianaName",
|
1571
|
-
get:
|
1633
|
+
get: /**
|
1634
|
+
* The IANA name of this zone, i.e. `Etc/UTC` or `Etc/GMT+/-nn`
|
1635
|
+
*
|
1636
|
+
* @override
|
1637
|
+
* @type {string}
|
1638
|
+
*/ function get() {
|
1572
1639
|
if (this.fixed === 0) {
|
1573
1640
|
return "Etc/UTC";
|
1574
1641
|
} else {
|
@@ -1577,38 +1644,71 @@ var singleton = null;
|
|
1577
1644
|
}
|
1578
1645
|
},
|
1579
1646
|
{
|
1580
|
-
/**
|
1647
|
+
/**
|
1648
|
+
* Returns the offset's common name at the specified timestamp.
|
1649
|
+
*
|
1650
|
+
* For fixed offset zones this equals to the zone name.
|
1651
|
+
* @override
|
1652
|
+
*/ key: "offsetName",
|
1581
1653
|
value: function offsetName() {
|
1582
1654
|
return this.name;
|
1583
1655
|
}
|
1584
1656
|
},
|
1585
1657
|
{
|
1586
|
-
/**
|
1658
|
+
/**
|
1659
|
+
* Returns the offset's value as a string
|
1660
|
+
* @override
|
1661
|
+
* @param {number} ts - Epoch milliseconds for which to get the offset
|
1662
|
+
* @param {string} format - What style of offset to return.
|
1663
|
+
* Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
1664
|
+
* @return {string}
|
1665
|
+
*/ key: "formatOffset",
|
1587
1666
|
value: function formatOffset1(ts, format) {
|
1588
1667
|
return formatOffset(this.fixed, format);
|
1589
1668
|
}
|
1590
1669
|
},
|
1591
1670
|
{
|
1592
1671
|
key: "isUniversal",
|
1593
|
-
get: /**
|
1672
|
+
get: /**
|
1673
|
+
* Returns whether the offset is known to be fixed for the whole year:
|
1674
|
+
* Always returns true for all fixed offset zones.
|
1675
|
+
* @override
|
1676
|
+
* @type {boolean}
|
1677
|
+
*/ function get() {
|
1594
1678
|
return true;
|
1595
1679
|
}
|
1596
1680
|
},
|
1597
1681
|
{
|
1598
|
-
/**
|
1682
|
+
/**
|
1683
|
+
* Return the offset in minutes for this zone at the specified timestamp.
|
1684
|
+
*
|
1685
|
+
* For fixed offset zones, this is constant and does not depend on a timestamp.
|
1686
|
+
* @override
|
1687
|
+
* @return {number}
|
1688
|
+
*/ key: "offset",
|
1599
1689
|
value: function offset() {
|
1600
1690
|
return this.fixed;
|
1601
1691
|
}
|
1602
1692
|
},
|
1603
1693
|
{
|
1604
|
-
/**
|
1694
|
+
/**
|
1695
|
+
* Return whether this Zone is equal to another zone (i.e. also fixed and same offset)
|
1696
|
+
* @override
|
1697
|
+
* @param {Zone} otherZone - the zone to compare
|
1698
|
+
* @return {boolean}
|
1699
|
+
*/ key: "equals",
|
1605
1700
|
value: function equals(otherZone) {
|
1606
1701
|
return otherZone.type === "fixed" && otherZone.fixed === this.fixed;
|
1607
1702
|
}
|
1608
1703
|
},
|
1609
1704
|
{
|
1610
1705
|
key: "isValid",
|
1611
|
-
get: /**
|
1706
|
+
get: /**
|
1707
|
+
* Return whether this Zone is valid:
|
1708
|
+
* All fixed offset zones are valid.
|
1709
|
+
* @override
|
1710
|
+
* @type {boolean}
|
1711
|
+
*/ function get() {
|
1612
1712
|
return true;
|
1613
1713
|
}
|
1614
1714
|
}
|
@@ -1745,6 +1845,146 @@ var singleton = null;
|
|
1745
1845
|
return new InvalidZone(input);
|
1746
1846
|
}
|
1747
1847
|
}
|
1848
|
+
var numberingSystems = {
|
1849
|
+
arab: "[٠-٩]",
|
1850
|
+
arabext: "[۰-۹]",
|
1851
|
+
bali: "[᭐-᭙]",
|
1852
|
+
beng: "[০-৯]",
|
1853
|
+
deva: "[०-९]",
|
1854
|
+
fullwide: "[0-9]",
|
1855
|
+
gujr: "[૦-૯]",
|
1856
|
+
hanidec: "[〇|一|二|三|四|五|六|七|八|九]",
|
1857
|
+
khmr: "[០-៩]",
|
1858
|
+
knda: "[೦-೯]",
|
1859
|
+
laoo: "[໐-໙]",
|
1860
|
+
limb: "[᥆-᥏]",
|
1861
|
+
mlym: "[൦-൯]",
|
1862
|
+
mong: "[᠐-᠙]",
|
1863
|
+
mymr: "[၀-၉]",
|
1864
|
+
orya: "[୦-୯]",
|
1865
|
+
tamldec: "[௦-௯]",
|
1866
|
+
telu: "[౦-౯]",
|
1867
|
+
thai: "[๐-๙]",
|
1868
|
+
tibt: "[༠-༩]",
|
1869
|
+
latn: "\\d"
|
1870
|
+
};
|
1871
|
+
var numberingSystemsUTF16 = {
|
1872
|
+
arab: [
|
1873
|
+
1632,
|
1874
|
+
1641
|
1875
|
+
],
|
1876
|
+
arabext: [
|
1877
|
+
1776,
|
1878
|
+
1785
|
1879
|
+
],
|
1880
|
+
bali: [
|
1881
|
+
6992,
|
1882
|
+
7001
|
1883
|
+
],
|
1884
|
+
beng: [
|
1885
|
+
2534,
|
1886
|
+
2543
|
1887
|
+
],
|
1888
|
+
deva: [
|
1889
|
+
2406,
|
1890
|
+
2415
|
1891
|
+
],
|
1892
|
+
fullwide: [
|
1893
|
+
65296,
|
1894
|
+
65303
|
1895
|
+
],
|
1896
|
+
gujr: [
|
1897
|
+
2790,
|
1898
|
+
2799
|
1899
|
+
],
|
1900
|
+
khmr: [
|
1901
|
+
6112,
|
1902
|
+
6121
|
1903
|
+
],
|
1904
|
+
knda: [
|
1905
|
+
3302,
|
1906
|
+
3311
|
1907
|
+
],
|
1908
|
+
laoo: [
|
1909
|
+
3792,
|
1910
|
+
3801
|
1911
|
+
],
|
1912
|
+
limb: [
|
1913
|
+
6470,
|
1914
|
+
6479
|
1915
|
+
],
|
1916
|
+
mlym: [
|
1917
|
+
3430,
|
1918
|
+
3439
|
1919
|
+
],
|
1920
|
+
mong: [
|
1921
|
+
6160,
|
1922
|
+
6169
|
1923
|
+
],
|
1924
|
+
mymr: [
|
1925
|
+
4160,
|
1926
|
+
4169
|
1927
|
+
],
|
1928
|
+
orya: [
|
1929
|
+
2918,
|
1930
|
+
2927
|
1931
|
+
],
|
1932
|
+
tamldec: [
|
1933
|
+
3046,
|
1934
|
+
3055
|
1935
|
+
],
|
1936
|
+
telu: [
|
1937
|
+
3174,
|
1938
|
+
3183
|
1939
|
+
],
|
1940
|
+
thai: [
|
1941
|
+
3664,
|
1942
|
+
3673
|
1943
|
+
],
|
1944
|
+
tibt: [
|
1945
|
+
3872,
|
1946
|
+
3881
|
1947
|
+
]
|
1948
|
+
};
|
1949
|
+
var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
|
1950
|
+
function parseDigits(str) {
|
1951
|
+
var value = parseInt(str, 10);
|
1952
|
+
if (isNaN(value)) {
|
1953
|
+
value = "";
|
1954
|
+
for(var i = 0; i < str.length; i++){
|
1955
|
+
var code = str.charCodeAt(i);
|
1956
|
+
if (str[i].search(numberingSystems.hanidec) !== -1) {
|
1957
|
+
value += hanidecChars.indexOf(str[i]);
|
1958
|
+
} else {
|
1959
|
+
for(var key in numberingSystemsUTF16){
|
1960
|
+
var _numberingSystemsUTF16_key = _sliced_to_array$1(numberingSystemsUTF16[key], 2), min = _numberingSystemsUTF16_key[0], max = _numberingSystemsUTF16_key[1];
|
1961
|
+
if (code >= min && code <= max) {
|
1962
|
+
value += code - min;
|
1963
|
+
}
|
1964
|
+
}
|
1965
|
+
}
|
1966
|
+
}
|
1967
|
+
return parseInt(value, 10);
|
1968
|
+
} else {
|
1969
|
+
return value;
|
1970
|
+
}
|
1971
|
+
}
|
1972
|
+
// cache of {numberingSystem: {append: regex}}
|
1973
|
+
var digitRegexCache = {};
|
1974
|
+
function resetDigitRegexCache() {
|
1975
|
+
digitRegexCache = {};
|
1976
|
+
}
|
1977
|
+
function digitRegex(param) {
|
1978
|
+
var numberingSystem = param.numberingSystem, append = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
1979
|
+
var ns = numberingSystem || "latn";
|
1980
|
+
if (!digitRegexCache[ns]) {
|
1981
|
+
digitRegexCache[ns] = {};
|
1982
|
+
}
|
1983
|
+
if (!digitRegexCache[ns][append]) {
|
1984
|
+
digitRegexCache[ns][append] = new RegExp("".concat(numberingSystems[ns]).concat(append));
|
1985
|
+
}
|
1986
|
+
return digitRegexCache[ns][append];
|
1987
|
+
}
|
1748
1988
|
var now = function() {
|
1749
1989
|
return Date.now();
|
1750
1990
|
}, defaultZone = "system", defaultLocale = null, defaultNumberingSystem = null, defaultOutputCalendar = null, twoDigitCutoffYear = 60, throwOnInvalid, defaultWeekSettings = null;
|
@@ -1860,16 +2100,17 @@ var now = function() {
|
|
1860
2100
|
{
|
1861
2101
|
key: "twoDigitCutoffYear",
|
1862
2102
|
get: /**
|
1863
|
-
* Get the cutoff year
|
2103
|
+
* Get the cutoff year for whether a 2-digit year string is interpreted in the current or previous century. Numbers higher than the cutoff will be considered to mean 19xx and numbers lower or equal to the cutoff will be considered 20xx.
|
1864
2104
|
* @type {number}
|
1865
2105
|
*/ function get() {
|
1866
2106
|
return twoDigitCutoffYear;
|
1867
2107
|
},
|
1868
2108
|
set: /**
|
1869
|
-
* Set the cutoff year
|
2109
|
+
* Set the cutoff year for whether a 2-digit year string is interpreted in the current or previous century. Numbers higher than the cutoff will be considered to mean 19xx and numbers lower or equal to the cutoff will be considered 20xx.
|
1870
2110
|
* @type {number}
|
1871
|
-
* @example Settings.twoDigitCutoffYear = 0 //
|
1872
|
-
* @example Settings.twoDigitCutoffYear =
|
2111
|
+
* @example Settings.twoDigitCutoffYear = 0 // all 'yy' are interpreted as 20th century
|
2112
|
+
* @example Settings.twoDigitCutoffYear = 99 // all 'yy' are interpreted as 21st century
|
2113
|
+
* @example Settings.twoDigitCutoffYear = 50 // '49' -> 2049; '50' -> 1950
|
1873
2114
|
* @example Settings.twoDigitCutoffYear = 1950 // interpreted as 50
|
1874
2115
|
* @example Settings.twoDigitCutoffYear = 2050 // ALSO interpreted as 50
|
1875
2116
|
*/ function set(cutoffYear) {
|
@@ -1899,6 +2140,8 @@ var now = function() {
|
|
1899
2140
|
*/ function resetCaches() {
|
1900
2141
|
Locale.resetCache();
|
1901
2142
|
IANAZone.resetCache();
|
2143
|
+
DateTime.resetCache();
|
2144
|
+
resetDigitRegexCache();
|
1902
2145
|
}
|
1903
2146
|
}
|
1904
2147
|
]);
|
@@ -2347,7 +2590,13 @@ function normalizeObject(obj, normalizer) {
|
|
2347
2590
|
}
|
2348
2591
|
return normalized;
|
2349
2592
|
}
|
2350
|
-
|
2593
|
+
/**
|
2594
|
+
* Returns the offset's value as a string
|
2595
|
+
* @param {number} ts - Epoch milliseconds for which to get the offset
|
2596
|
+
* @param {string} format - What style of offset to return.
|
2597
|
+
* Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
2598
|
+
* @return {string}
|
2599
|
+
*/ function formatOffset(offset, format) {
|
2351
2600
|
var hours = Math.trunc(Math.abs(offset / 60)), minutes = Math.trunc(Math.abs(offset % 60)), sign = offset >= 0 ? "+" : "-";
|
2352
2601
|
switch(format){
|
2353
2602
|
case "short":
|
@@ -4789,7 +5038,7 @@ function validateStartEnd(start, end) {
|
|
4789
5038
|
},
|
4790
5039
|
{
|
4791
5040
|
/**
|
4792
|
-
*
|
5041
|
+
* Returns true if this Interval fully contains the specified Interval, specifically if the intersect (of this Interval and the other Interval) is equal to the other Interval; false otherwise.
|
4793
5042
|
* @param {Interval} other
|
4794
5043
|
* @return {boolean}
|
4795
5044
|
*/ key: "engulfs",
|
@@ -5562,134 +5811,6 @@ function diff(earlier, later, units, opts) {
|
|
5562
5811
|
return duration;
|
5563
5812
|
}
|
5564
5813
|
}
|
5565
|
-
var numberingSystems = {
|
5566
|
-
arab: "[٠-٩]",
|
5567
|
-
arabext: "[۰-۹]",
|
5568
|
-
bali: "[᭐-᭙]",
|
5569
|
-
beng: "[০-৯]",
|
5570
|
-
deva: "[०-९]",
|
5571
|
-
fullwide: "[0-9]",
|
5572
|
-
gujr: "[૦-૯]",
|
5573
|
-
hanidec: "[〇|一|二|三|四|五|六|七|八|九]",
|
5574
|
-
khmr: "[០-៩]",
|
5575
|
-
knda: "[೦-೯]",
|
5576
|
-
laoo: "[໐-໙]",
|
5577
|
-
limb: "[᥆-᥏]",
|
5578
|
-
mlym: "[൦-൯]",
|
5579
|
-
mong: "[᠐-᠙]",
|
5580
|
-
mymr: "[၀-၉]",
|
5581
|
-
orya: "[୦-୯]",
|
5582
|
-
tamldec: "[௦-௯]",
|
5583
|
-
telu: "[౦-౯]",
|
5584
|
-
thai: "[๐-๙]",
|
5585
|
-
tibt: "[༠-༩]",
|
5586
|
-
latn: "\\d"
|
5587
|
-
};
|
5588
|
-
var numberingSystemsUTF16 = {
|
5589
|
-
arab: [
|
5590
|
-
1632,
|
5591
|
-
1641
|
5592
|
-
],
|
5593
|
-
arabext: [
|
5594
|
-
1776,
|
5595
|
-
1785
|
5596
|
-
],
|
5597
|
-
bali: [
|
5598
|
-
6992,
|
5599
|
-
7001
|
5600
|
-
],
|
5601
|
-
beng: [
|
5602
|
-
2534,
|
5603
|
-
2543
|
5604
|
-
],
|
5605
|
-
deva: [
|
5606
|
-
2406,
|
5607
|
-
2415
|
5608
|
-
],
|
5609
|
-
fullwide: [
|
5610
|
-
65296,
|
5611
|
-
65303
|
5612
|
-
],
|
5613
|
-
gujr: [
|
5614
|
-
2790,
|
5615
|
-
2799
|
5616
|
-
],
|
5617
|
-
khmr: [
|
5618
|
-
6112,
|
5619
|
-
6121
|
5620
|
-
],
|
5621
|
-
knda: [
|
5622
|
-
3302,
|
5623
|
-
3311
|
5624
|
-
],
|
5625
|
-
laoo: [
|
5626
|
-
3792,
|
5627
|
-
3801
|
5628
|
-
],
|
5629
|
-
limb: [
|
5630
|
-
6470,
|
5631
|
-
6479
|
5632
|
-
],
|
5633
|
-
mlym: [
|
5634
|
-
3430,
|
5635
|
-
3439
|
5636
|
-
],
|
5637
|
-
mong: [
|
5638
|
-
6160,
|
5639
|
-
6169
|
5640
|
-
],
|
5641
|
-
mymr: [
|
5642
|
-
4160,
|
5643
|
-
4169
|
5644
|
-
],
|
5645
|
-
orya: [
|
5646
|
-
2918,
|
5647
|
-
2927
|
5648
|
-
],
|
5649
|
-
tamldec: [
|
5650
|
-
3046,
|
5651
|
-
3055
|
5652
|
-
],
|
5653
|
-
telu: [
|
5654
|
-
3174,
|
5655
|
-
3183
|
5656
|
-
],
|
5657
|
-
thai: [
|
5658
|
-
3664,
|
5659
|
-
3673
|
5660
|
-
],
|
5661
|
-
tibt: [
|
5662
|
-
3872,
|
5663
|
-
3881
|
5664
|
-
]
|
5665
|
-
};
|
5666
|
-
var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
|
5667
|
-
function parseDigits(str) {
|
5668
|
-
var value = parseInt(str, 10);
|
5669
|
-
if (isNaN(value)) {
|
5670
|
-
value = "";
|
5671
|
-
for(var i = 0; i < str.length; i++){
|
5672
|
-
var code = str.charCodeAt(i);
|
5673
|
-
if (str[i].search(numberingSystems.hanidec) !== -1) {
|
5674
|
-
value += hanidecChars.indexOf(str[i]);
|
5675
|
-
} else {
|
5676
|
-
for(var key in numberingSystemsUTF16){
|
5677
|
-
var _numberingSystemsUTF16_key = _sliced_to_array$1(numberingSystemsUTF16[key], 2), min = _numberingSystemsUTF16_key[0], max = _numberingSystemsUTF16_key[1];
|
5678
|
-
if (code >= min && code <= max) {
|
5679
|
-
value += code - min;
|
5680
|
-
}
|
5681
|
-
}
|
5682
|
-
}
|
5683
|
-
}
|
5684
|
-
return parseInt(value, 10);
|
5685
|
-
} else {
|
5686
|
-
return value;
|
5687
|
-
}
|
5688
|
-
}
|
5689
|
-
function digitRegex(param) {
|
5690
|
-
var numberingSystem = param.numberingSystem, append = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
5691
|
-
return new RegExp("".concat(numberingSystems[numberingSystem || "latn"]).concat(append));
|
5692
|
-
}
|
5693
5814
|
var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
|
5694
5815
|
function intUnit(regex) {
|
5695
5816
|
var post = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function(i) {
|
@@ -6113,38 +6234,74 @@ function expandMacroTokens(tokens, locale) {
|
|
6113
6234
|
}
|
6114
6235
|
/**
|
6115
6236
|
* @private
|
6116
|
-
*/
|
6117
|
-
|
6118
|
-
|
6119
|
-
|
6120
|
-
|
6121
|
-
|
6122
|
-
|
6123
|
-
|
6124
|
-
|
6125
|
-
|
6126
|
-
|
6127
|
-
};
|
6128
|
-
|
6129
|
-
|
6130
|
-
|
6131
|
-
|
6132
|
-
undefined
|
6133
|
-
], 3), result = _ref[0], zone = _ref[1], specificOffset = _ref[2];
|
6134
|
-
if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
|
6135
|
-
throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");
|
6237
|
+
*/ var TokenParser = /*#__PURE__*/ function() {
|
6238
|
+
function TokenParser(locale, format) {
|
6239
|
+
_class_call_check$3(this, TokenParser);
|
6240
|
+
this.locale = locale;
|
6241
|
+
this.format = format;
|
6242
|
+
this.tokens = expandMacroTokens(Formatter.parseFormat(format), locale);
|
6243
|
+
this.units = this.tokens.map(function(t) {
|
6244
|
+
return unitForToken(t, locale);
|
6245
|
+
});
|
6246
|
+
this.disqualifyingUnit = this.units.find(function(t) {
|
6247
|
+
return t.invalidReason;
|
6248
|
+
});
|
6249
|
+
if (!this.disqualifyingUnit) {
|
6250
|
+
var _buildRegex = _sliced_to_array$1(buildRegex(this.units), 2), regexString = _buildRegex[0], handlers = _buildRegex[1];
|
6251
|
+
this.regex = RegExp(regexString, "i");
|
6252
|
+
this.handlers = handlers;
|
6136
6253
|
}
|
6137
|
-
return {
|
6138
|
-
input: input,
|
6139
|
-
tokens: tokens,
|
6140
|
-
regex: regex,
|
6141
|
-
rawMatches: rawMatches,
|
6142
|
-
matches: matches,
|
6143
|
-
result: result,
|
6144
|
-
zone: zone,
|
6145
|
-
specificOffset: specificOffset
|
6146
|
-
};
|
6147
6254
|
}
|
6255
|
+
_create_class$2(TokenParser, [
|
6256
|
+
{
|
6257
|
+
key: "explainFromTokens",
|
6258
|
+
value: function explainFromTokens(input) {
|
6259
|
+
if (!this.isValid) {
|
6260
|
+
return {
|
6261
|
+
input: input,
|
6262
|
+
tokens: this.tokens,
|
6263
|
+
invalidReason: this.invalidReason
|
6264
|
+
};
|
6265
|
+
} else {
|
6266
|
+
var _match = _sliced_to_array$1(match(input, this.regex, this.handlers), 2), rawMatches = _match[0], matches = _match[1], _ref = _sliced_to_array$1(matches ? dateTimeFromMatches(matches) : [
|
6267
|
+
null,
|
6268
|
+
null,
|
6269
|
+
undefined
|
6270
|
+
], 3), result = _ref[0], zone = _ref[1], specificOffset = _ref[2];
|
6271
|
+
if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
|
6272
|
+
throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");
|
6273
|
+
}
|
6274
|
+
return {
|
6275
|
+
input: input,
|
6276
|
+
tokens: this.tokens,
|
6277
|
+
regex: this.regex,
|
6278
|
+
rawMatches: rawMatches,
|
6279
|
+
matches: matches,
|
6280
|
+
result: result,
|
6281
|
+
zone: zone,
|
6282
|
+
specificOffset: specificOffset
|
6283
|
+
};
|
6284
|
+
}
|
6285
|
+
}
|
6286
|
+
},
|
6287
|
+
{
|
6288
|
+
key: "isValid",
|
6289
|
+
get: function get() {
|
6290
|
+
return !this.disqualifyingUnit;
|
6291
|
+
}
|
6292
|
+
},
|
6293
|
+
{
|
6294
|
+
key: "invalidReason",
|
6295
|
+
get: function get() {
|
6296
|
+
return this.disqualifyingUnit ? this.disqualifyingUnit.invalidReason : null;
|
6297
|
+
}
|
6298
|
+
}
|
6299
|
+
]);
|
6300
|
+
return TokenParser;
|
6301
|
+
}();
|
6302
|
+
function explainFromTokens(locale, input, format) {
|
6303
|
+
var parser = new TokenParser(locale, format);
|
6304
|
+
return parser.explainFromTokens(input);
|
6148
6305
|
}
|
6149
6306
|
function parseFromTokens(locale, input, format) {
|
6150
6307
|
var _explainFromTokens = explainFromTokens(locale, input, format), result = _explainFromTokens.result, zone = _explainFromTokens.zone, specificOffset = _explainFromTokens.specificOffset, invalidReason = _explainFromTokens.invalidReason;
|
@@ -6450,11 +6607,43 @@ function normalizeUnitWithLocalWeeks(unit) {
|
|
6450
6607
|
return normalizeUnit(unit);
|
6451
6608
|
}
|
6452
6609
|
}
|
6610
|
+
// cache offsets for zones based on the current timestamp when this function is
|
6611
|
+
// first called. When we are handling a datetime from components like (year,
|
6612
|
+
// month, day, hour) in a time zone, we need a guess about what the timezone
|
6613
|
+
// offset is so that we can convert into a UTC timestamp. One way is to find the
|
6614
|
+
// offset of now in the zone. The actual date may have a different offset (for
|
6615
|
+
// example, if we handle a date in June while we're in December in a zone that
|
6616
|
+
// observes DST), but we can check and adjust that.
|
6617
|
+
//
|
6618
|
+
// When handling many dates, calculating the offset for now every time is
|
6619
|
+
// expensive. It's just a guess, so we can cache the offset to use even if we
|
6620
|
+
// are right on a time change boundary (we'll just correct in the other
|
6621
|
+
// direction). Using a timestamp from first read is a slight optimization for
|
6622
|
+
// handling dates close to the current date, since those dates will usually be
|
6623
|
+
// in the same offset (we could set the timestamp statically, instead). We use a
|
6624
|
+
// single timestamp for all zones to make things a bit more predictable.
|
6625
|
+
//
|
6626
|
+
// This is safe for quickDT (used by local() and utc()) because we don't fill in
|
6627
|
+
// higher-order units from tsNow (as we do in fromObject, this requires that
|
6628
|
+
// offset is calculated from tsNow).
|
6629
|
+
function guessOffsetForZone(zone) {
|
6630
|
+
if (!zoneOffsetGuessCache[zone]) {
|
6631
|
+
if (zoneOffsetTs === undefined) {
|
6632
|
+
zoneOffsetTs = Settings.now();
|
6633
|
+
}
|
6634
|
+
zoneOffsetGuessCache[zone] = zone.offset(zoneOffsetTs);
|
6635
|
+
}
|
6636
|
+
return zoneOffsetGuessCache[zone];
|
6637
|
+
}
|
6453
6638
|
// this is a dumbed down version of fromObject() that runs about 60% faster
|
6454
6639
|
// but doesn't do any validation, makes a bunch of assumptions about what units
|
6455
6640
|
// are present, and so on.
|
6456
6641
|
function quickDT(obj, opts) {
|
6457
|
-
var zone = normalizeZone(opts.zone, Settings.defaultZone)
|
6642
|
+
var zone = normalizeZone(opts.zone, Settings.defaultZone);
|
6643
|
+
if (!zone.isValid) {
|
6644
|
+
return DateTime.invalid(unsupportedZone(zone));
|
6645
|
+
}
|
6646
|
+
var loc = Locale.fromObject(opts);
|
6458
6647
|
var ts, o;
|
6459
6648
|
// assume we have the higher-order units
|
6460
6649
|
if (!isUndefined(obj.year)) {
|
@@ -6484,11 +6673,11 @@ function quickDT(obj, opts) {
|
|
6484
6673
|
if (invalid) {
|
6485
6674
|
return DateTime.invalid(invalid);
|
6486
6675
|
}
|
6487
|
-
var offsetProvis = zone
|
6676
|
+
var offsetProvis = guessOffsetForZone(zone);
|
6488
6677
|
var ref;
|
6489
6678
|
ref = _sliced_to_array$1(objToTS(obj, offsetProvis, zone), 2), ts = ref[0], o = ref[1];
|
6490
6679
|
} else {
|
6491
|
-
ts =
|
6680
|
+
ts = Settings.now();
|
6492
6681
|
}
|
6493
6682
|
return new DateTime({
|
6494
6683
|
ts: ts,
|
@@ -6552,6 +6741,15 @@ function lastOpts(argList) {
|
|
6552
6741
|
args
|
6553
6742
|
];
|
6554
6743
|
}
|
6744
|
+
/**
|
6745
|
+
* Timestamp to use for cached zone offset guesses (exposed for test)
|
6746
|
+
*/ var zoneOffsetTs;
|
6747
|
+
/**
|
6748
|
+
* Cache for zone offset guesses (exposed for test).
|
6749
|
+
*
|
6750
|
+
* This optimizes quickDT via guessOffsetForZone to avoid repeated calls of
|
6751
|
+
* zone.offset().
|
6752
|
+
*/ var zoneOffsetGuessCache = {};
|
6555
6753
|
/**
|
6556
6754
|
* 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.
|
6557
6755
|
*
|
@@ -6589,7 +6787,9 @@ function lastOpts(argList) {
|
|
6589
6787
|
config.old.o
|
6590
6788
|
], c = ref[0], o = ref[1];
|
6591
6789
|
} else {
|
6592
|
-
|
6790
|
+
// If an offset has been passed and we have not been called from
|
6791
|
+
// clone(), we can trust it and avoid the offset calculation.
|
6792
|
+
var ot = isNumber(config.o) && !config.old ? config.o : zone.offset(this.ts);
|
6593
6793
|
c = tsToObj(this.ts, ot);
|
6594
6794
|
invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null;
|
6595
6795
|
c = invalid ? null : c;
|
@@ -7922,6 +8122,7 @@ function lastOpts(argList) {
|
|
7922
8122
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
7923
8123
|
* @param {string} [options.outputCalendar] - the output calendar to set on the resulting DateTime instance
|
7924
8124
|
* @param {string} [options.numberingSystem] - the numbering system to set on the resulting DateTime instance
|
8125
|
+
* @param {string} [options.weekSettings] - the week settings to set on the resulting DateTime instance
|
7925
8126
|
* @example DateTime.utc() //~> now
|
7926
8127
|
* @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
|
7927
8128
|
* @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
|
@@ -7981,13 +8182,14 @@ function lastOpts(argList) {
|
|
7981
8182
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
7982
8183
|
* @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
7983
8184
|
* @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8185
|
+
* @param {string} options.weekSettings - the week settings to set on the resulting DateTime instance
|
7984
8186
|
* @return {DateTime}
|
7985
8187
|
*/ function fromMillis(milliseconds) {
|
7986
8188
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
7987
8189
|
if (!isNumber(milliseconds)) {
|
7988
8190
|
throw new InvalidArgumentError("fromMillis requires a numerical input, but received a ".concat(typeof milliseconds === "undefined" ? "undefined" : _type_of$2(milliseconds), " with value ").concat(milliseconds));
|
7989
8191
|
} else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
|
7990
|
-
// this isn't perfect because
|
8192
|
+
// this isn't perfect because we can still end up out of range because of additional shifting, but it's a start
|
7991
8193
|
return DateTime.invalid("Timestamp out of range");
|
7992
8194
|
} else {
|
7993
8195
|
return new DateTime({
|
@@ -8008,6 +8210,7 @@ function lastOpts(argList) {
|
|
8008
8210
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
8009
8211
|
* @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8010
8212
|
* @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8213
|
+
* @param {string} options.weekSettings - the week settings to set on the resulting DateTime instance
|
8011
8214
|
* @return {DateTime}
|
8012
8215
|
*/ function fromSeconds(seconds) {
|
8013
8216
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
@@ -8046,6 +8249,7 @@ function lastOpts(argList) {
|
|
8046
8249
|
* @param {string} [opts.locale='system\'s locale'] - a locale to set on the resulting DateTime instance
|
8047
8250
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8048
8251
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8252
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8049
8253
|
* @example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'
|
8050
8254
|
* @example DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'
|
8051
8255
|
* @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06
|
@@ -8137,6 +8341,9 @@ function lastOpts(argList) {
|
|
8137
8341
|
if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) {
|
8138
8342
|
return DateTime.invalid("mismatched weekday", "you can't specify both a weekday of ".concat(normalized.weekday, " and a date of ").concat(inst.toISO()));
|
8139
8343
|
}
|
8344
|
+
if (!inst.isValid) {
|
8345
|
+
return DateTime.invalid(inst.invalid);
|
8346
|
+
}
|
8140
8347
|
return inst;
|
8141
8348
|
}
|
8142
8349
|
},
|
@@ -8151,6 +8358,7 @@ function lastOpts(argList) {
|
|
8151
8358
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
8152
8359
|
* @param {string} [opts.outputCalendar] - the output calendar to set on the resulting DateTime instance
|
8153
8360
|
* @param {string} [opts.numberingSystem] - the numbering system to set on the resulting DateTime instance
|
8361
|
+
* @param {string} [opts.weekSettings] - the week settings to set on the resulting DateTime instance
|
8154
8362
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123')
|
8155
8363
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00')
|
8156
8364
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true})
|
@@ -8174,6 +8382,7 @@ function lastOpts(argList) {
|
|
8174
8382
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
8175
8383
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8176
8384
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8385
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8177
8386
|
* @example DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT')
|
8178
8387
|
* @example DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600')
|
8179
8388
|
* @example DateTime.fromRFC2822('25 Nov 2016 13:23 Z')
|
@@ -8196,6 +8405,7 @@ function lastOpts(argList) {
|
|
8196
8405
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
8197
8406
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8198
8407
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8408
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8199
8409
|
* @example DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT')
|
8200
8410
|
* @example DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT')
|
8201
8411
|
* @example DateTime.fromHTTP('Sun Nov 6 08:49:37 1994')
|
@@ -8218,6 +8428,7 @@ function lastOpts(argList) {
|
|
8218
8428
|
* @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
|
8219
8429
|
* @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
|
8220
8430
|
* @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
|
8431
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8221
8432
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8222
8433
|
* @return {DateTime}
|
8223
8434
|
*/ function fromFormat(text, fmt) {
|
@@ -8257,6 +8468,7 @@ function lastOpts(argList) {
|
|
8257
8468
|
* @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
|
8258
8469
|
* @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
|
8259
8470
|
* @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
|
8471
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8260
8472
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8261
8473
|
* @example DateTime.fromSQL('2017-05-15')
|
8262
8474
|
* @example DateTime.fromSQL('2017-05-15 09:12:34')
|
@@ -8336,6 +8548,13 @@ function lastOpts(argList) {
|
|
8336
8548
|
}).join("");
|
8337
8549
|
}
|
8338
8550
|
},
|
8551
|
+
{
|
8552
|
+
key: "resetCache",
|
8553
|
+
value: function resetCache() {
|
8554
|
+
zoneOffsetTs = undefined;
|
8555
|
+
zoneOffsetGuessCache = {};
|
8556
|
+
}
|
8557
|
+
},
|
8339
8558
|
{
|
8340
8559
|
key: "min",
|
8341
8560
|
value: /**
|
@@ -8400,6 +8619,61 @@ function lastOpts(argList) {
|
|
8400
8619
|
return DateTime.fromFormatExplain(text, fmt, options);
|
8401
8620
|
}
|
8402
8621
|
},
|
8622
|
+
{
|
8623
|
+
key: "buildFormatParser",
|
8624
|
+
value: /**
|
8625
|
+
* Build a parser for `fmt` using the given locale. This parser can be passed
|
8626
|
+
* to {@link DateTime.fromFormatParser} to a parse a date in this format. This
|
8627
|
+
* can be used to optimize cases where many dates need to be parsed in a
|
8628
|
+
* specific format.
|
8629
|
+
*
|
8630
|
+
* @param {String} fmt - the format the string is expected to be in (see
|
8631
|
+
* description)
|
8632
|
+
* @param {Object} options - options used to set locale and numberingSystem
|
8633
|
+
* for parser
|
8634
|
+
* @returns {TokenParser} - opaque object to be used
|
8635
|
+
*/ function buildFormatParser(fmt) {
|
8636
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
8637
|
+
var _options_locale = options.locale, locale = _options_locale === void 0 ? null : _options_locale, _options_numberingSystem = options.numberingSystem, numberingSystem = _options_numberingSystem === void 0 ? null : _options_numberingSystem, localeToUse = Locale.fromOpts({
|
8638
|
+
locale: locale,
|
8639
|
+
numberingSystem: numberingSystem,
|
8640
|
+
defaultToEN: true
|
8641
|
+
});
|
8642
|
+
return new TokenParser(localeToUse, fmt);
|
8643
|
+
}
|
8644
|
+
},
|
8645
|
+
{
|
8646
|
+
key: "fromFormatParser",
|
8647
|
+
value: /**
|
8648
|
+
* Create a DateTime from an input string and format parser.
|
8649
|
+
*
|
8650
|
+
* The format parser must have been created with the same locale as this call.
|
8651
|
+
*
|
8652
|
+
* @param {String} text - the string to parse
|
8653
|
+
* @param {TokenParser} formatParser - parser from {@link DateTime.buildFormatParser}
|
8654
|
+
* @param {Object} opts - options taken by fromFormat()
|
8655
|
+
* @returns {DateTime}
|
8656
|
+
*/ function fromFormatParser(text, formatParser) {
|
8657
|
+
var opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
8658
|
+
if (isUndefined(text) || isUndefined(formatParser)) {
|
8659
|
+
throw new InvalidArgumentError("fromFormatParser requires an input string and a format parser");
|
8660
|
+
}
|
8661
|
+
var _opts_locale = opts.locale, locale = _opts_locale === void 0 ? null : _opts_locale, _opts_numberingSystem = opts.numberingSystem, numberingSystem = _opts_numberingSystem === void 0 ? null : _opts_numberingSystem, localeToUse = Locale.fromOpts({
|
8662
|
+
locale: locale,
|
8663
|
+
numberingSystem: numberingSystem,
|
8664
|
+
defaultToEN: true
|
8665
|
+
});
|
8666
|
+
if (!localeToUse.equals(formatParser.locale)) {
|
8667
|
+
throw new InvalidArgumentError("fromFormatParser called with a locale of ".concat(localeToUse, ", ") + "but the format parser was created for ".concat(formatParser.locale));
|
8668
|
+
}
|
8669
|
+
var _formatParser_explainFromTokens = formatParser.explainFromTokens(text), result = _formatParser_explainFromTokens.result, zone = _formatParser_explainFromTokens.zone, specificOffset = _formatParser_explainFromTokens.specificOffset, invalidReason = _formatParser_explainFromTokens.invalidReason;
|
8670
|
+
if (invalidReason) {
|
8671
|
+
return DateTime.invalid(invalidReason);
|
8672
|
+
} else {
|
8673
|
+
return parseDataToDateTime(result, zone, opts, "format ".concat(formatParser.format), text, specificOffset);
|
8674
|
+
}
|
8675
|
+
}
|
8676
|
+
},
|
8403
8677
|
{
|
8404
8678
|
key: "DATE_SHORT",
|
8405
8679
|
get: // FORMAT PRESETS
|
@@ -8615,7 +8889,7 @@ function lastOpts(argList) {
|
|
8615
8889
|
throw new InvalidArgumentError("Unknown datetime argument: ".concat(dateTimeish, ", of type ").concat(typeof dateTimeish === "undefined" ? "undefined" : _type_of$2(dateTimeish)));
|
8616
8890
|
}
|
8617
8891
|
}
|
8618
|
-
var VERSION = "3.
|
8892
|
+
var VERSION = "3.5.0";
|
8619
8893
|
luxon.DateTime = DateTime;
|
8620
8894
|
luxon.Duration = Duration;
|
8621
8895
|
luxon.FixedOffsetZone = FixedOffsetZone;
|