@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.esm.js
CHANGED
@@ -553,7 +553,12 @@ var DATETIME_HUGE_WITH_SECONDS = {
|
|
553
553
|
},
|
554
554
|
{
|
555
555
|
key: "ianaName",
|
556
|
-
get:
|
556
|
+
get: /**
|
557
|
+
* The IANA name of this zone.
|
558
|
+
* Defaults to `name` if not overwritten by a subclass.
|
559
|
+
* @abstract
|
560
|
+
* @type {string}
|
561
|
+
*/ function get() {
|
557
562
|
return this.name;
|
558
563
|
}
|
559
564
|
},
|
@@ -776,37 +781,70 @@ var ianaZoneCache = {};
|
|
776
781
|
_create_class$2(IANAZone, [
|
777
782
|
{
|
778
783
|
key: "type",
|
779
|
-
get: /**
|
784
|
+
get: /**
|
785
|
+
* The type of zone. `iana` for all instances of `IANAZone`.
|
786
|
+
* @override
|
787
|
+
* @type {string}
|
788
|
+
*/ function get() {
|
780
789
|
return "iana";
|
781
790
|
}
|
782
791
|
},
|
783
792
|
{
|
784
793
|
key: "name",
|
785
|
-
get: /**
|
794
|
+
get: /**
|
795
|
+
* The name of this zone (i.e. the IANA zone name).
|
796
|
+
* @override
|
797
|
+
* @type {string}
|
798
|
+
*/ function get() {
|
786
799
|
return this.zoneName;
|
787
800
|
}
|
788
801
|
},
|
789
802
|
{
|
790
803
|
key: "isUniversal",
|
791
|
-
get: /**
|
804
|
+
get: /**
|
805
|
+
* Returns whether the offset is known to be fixed for the whole year:
|
806
|
+
* Always returns false for all IANA zones.
|
807
|
+
* @override
|
808
|
+
* @type {boolean}
|
809
|
+
*/ function get() {
|
792
810
|
return false;
|
793
811
|
}
|
794
812
|
},
|
795
813
|
{
|
796
|
-
/**
|
814
|
+
/**
|
815
|
+
* Returns the offset's common name (such as EST) at the specified timestamp
|
816
|
+
* @override
|
817
|
+
* @param {number} ts - Epoch milliseconds for which to get the name
|
818
|
+
* @param {Object} opts - Options to affect the format
|
819
|
+
* @param {string} opts.format - What style of offset to return. Accepts 'long' or 'short'.
|
820
|
+
* @param {string} opts.locale - What locale to return the offset name in.
|
821
|
+
* @return {string}
|
822
|
+
*/ key: "offsetName",
|
797
823
|
value: function offsetName(ts, param) {
|
798
824
|
var format = param.format, locale = param.locale;
|
799
825
|
return parseZoneInfo(ts, format, locale, this.name);
|
800
826
|
}
|
801
827
|
},
|
802
828
|
{
|
803
|
-
/**
|
829
|
+
/**
|
830
|
+
* Returns the offset's value as a string
|
831
|
+
* @override
|
832
|
+
* @param {number} ts - Epoch milliseconds for which to get the offset
|
833
|
+
* @param {string} format - What style of offset to return.
|
834
|
+
* Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
835
|
+
* @return {string}
|
836
|
+
*/ key: "formatOffset",
|
804
837
|
value: function formatOffset1(ts, format) {
|
805
838
|
return formatOffset(this.offset(ts), format);
|
806
839
|
}
|
807
840
|
},
|
808
841
|
{
|
809
|
-
/**
|
842
|
+
/**
|
843
|
+
* Return the offset in minutes for this zone at the specified timestamp.
|
844
|
+
* @override
|
845
|
+
* @param {number} ts - Epoch milliseconds for which to compute the offset
|
846
|
+
* @return {number}
|
847
|
+
*/ key: "offset",
|
810
848
|
value: function offset(ts) {
|
811
849
|
var date = new Date(ts);
|
812
850
|
if (isNaN(date)) return NaN;
|
@@ -833,14 +871,23 @@ var ianaZoneCache = {};
|
|
833
871
|
}
|
834
872
|
},
|
835
873
|
{
|
836
|
-
/**
|
874
|
+
/**
|
875
|
+
* Return whether this Zone is equal to another zone
|
876
|
+
* @override
|
877
|
+
* @param {Zone} otherZone - the zone to compare
|
878
|
+
* @return {boolean}
|
879
|
+
*/ key: "equals",
|
837
880
|
value: function equals(otherZone) {
|
838
881
|
return otherZone.type === "iana" && otherZone.name === this.name;
|
839
882
|
}
|
840
883
|
},
|
841
884
|
{
|
842
885
|
key: "isValid",
|
843
|
-
get: /**
|
886
|
+
get: /**
|
887
|
+
* Return whether this Zone is valid.
|
888
|
+
* @override
|
889
|
+
* @type {boolean}
|
890
|
+
*/ function get() {
|
844
891
|
return this.valid;
|
845
892
|
}
|
846
893
|
}
|
@@ -874,7 +921,7 @@ var ianaZoneCache = {};
|
|
874
921
|
* @param {string} s - The string to check validity on
|
875
922
|
* @example IANAZone.isValidSpecifier("America/New_York") //=> true
|
876
923
|
* @example IANAZone.isValidSpecifier("Sport~~blorp") //=> false
|
877
|
-
* @deprecated
|
924
|
+
* @deprecated For backward compatibility, this forwards to isValidZone, better use `isValidZone()` directly instead.
|
878
925
|
* @return {boolean}
|
879
926
|
*/ function isValidSpecifier(s) {
|
880
927
|
return this.isValidZone(s);
|
@@ -1491,6 +1538,12 @@ var fallbackWeekSettings = {
|
|
1491
1538
|
value: function equals(other) {
|
1492
1539
|
return this.locale === other.locale && this.numberingSystem === other.numberingSystem && this.outputCalendar === other.outputCalendar;
|
1493
1540
|
}
|
1541
|
+
},
|
1542
|
+
{
|
1543
|
+
key: "toString",
|
1544
|
+
value: function toString() {
|
1545
|
+
return "Locale(".concat(this.locale, ", ").concat(this.numberingSystem, ", ").concat(this.outputCalendar, ")");
|
1546
|
+
}
|
1494
1547
|
}
|
1495
1548
|
], [
|
1496
1549
|
{
|
@@ -1504,7 +1557,7 @@ var fallbackWeekSettings = {
|
|
1504
1557
|
value: function create(locale, numberingSystem, outputCalendar, weekSettings) {
|
1505
1558
|
var defaultToEN = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : false;
|
1506
1559
|
var specifiedLocale = locale || Settings.defaultLocale;
|
1507
|
-
// the system locale is useful for human
|
1560
|
+
// the system locale is useful for human-readable strings but annoying for parsing/formatting known formats
|
1508
1561
|
var localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale());
|
1509
1562
|
var numberingSystemR = numberingSystem || Settings.defaultNumberingSystem;
|
1510
1563
|
var outputCalendarR = outputCalendar || Settings.defaultOutputCalendar;
|
@@ -1548,19 +1601,33 @@ var singleton = null;
|
|
1548
1601
|
_create_class$2(FixedOffsetZone, [
|
1549
1602
|
{
|
1550
1603
|
key: "type",
|
1551
|
-
get: /**
|
1604
|
+
get: /**
|
1605
|
+
* The type of zone. `fixed` for all instances of `FixedOffsetZone`.
|
1606
|
+
* @override
|
1607
|
+
* @type {string}
|
1608
|
+
*/ function get() {
|
1552
1609
|
return "fixed";
|
1553
1610
|
}
|
1554
1611
|
},
|
1555
1612
|
{
|
1556
1613
|
key: "name",
|
1557
|
-
get: /**
|
1614
|
+
get: /**
|
1615
|
+
* The name of this zone.
|
1616
|
+
* All fixed zones' names always start with "UTC" (plus optional offset)
|
1617
|
+
* @override
|
1618
|
+
* @type {string}
|
1619
|
+
*/ function get() {
|
1558
1620
|
return this.fixed === 0 ? "UTC" : "UTC".concat(formatOffset(this.fixed, "narrow"));
|
1559
1621
|
}
|
1560
1622
|
},
|
1561
1623
|
{
|
1562
1624
|
key: "ianaName",
|
1563
|
-
get:
|
1625
|
+
get: /**
|
1626
|
+
* The IANA name of this zone, i.e. `Etc/UTC` or `Etc/GMT+/-nn`
|
1627
|
+
*
|
1628
|
+
* @override
|
1629
|
+
* @type {string}
|
1630
|
+
*/ function get() {
|
1564
1631
|
if (this.fixed === 0) {
|
1565
1632
|
return "Etc/UTC";
|
1566
1633
|
} else {
|
@@ -1569,38 +1636,71 @@ var singleton = null;
|
|
1569
1636
|
}
|
1570
1637
|
},
|
1571
1638
|
{
|
1572
|
-
/**
|
1639
|
+
/**
|
1640
|
+
* Returns the offset's common name at the specified timestamp.
|
1641
|
+
*
|
1642
|
+
* For fixed offset zones this equals to the zone name.
|
1643
|
+
* @override
|
1644
|
+
*/ key: "offsetName",
|
1573
1645
|
value: function offsetName() {
|
1574
1646
|
return this.name;
|
1575
1647
|
}
|
1576
1648
|
},
|
1577
1649
|
{
|
1578
|
-
/**
|
1650
|
+
/**
|
1651
|
+
* Returns the offset's value as a string
|
1652
|
+
* @override
|
1653
|
+
* @param {number} ts - Epoch milliseconds for which to get the offset
|
1654
|
+
* @param {string} format - What style of offset to return.
|
1655
|
+
* Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
1656
|
+
* @return {string}
|
1657
|
+
*/ key: "formatOffset",
|
1579
1658
|
value: function formatOffset1(ts, format) {
|
1580
1659
|
return formatOffset(this.fixed, format);
|
1581
1660
|
}
|
1582
1661
|
},
|
1583
1662
|
{
|
1584
1663
|
key: "isUniversal",
|
1585
|
-
get: /**
|
1664
|
+
get: /**
|
1665
|
+
* Returns whether the offset is known to be fixed for the whole year:
|
1666
|
+
* Always returns true for all fixed offset zones.
|
1667
|
+
* @override
|
1668
|
+
* @type {boolean}
|
1669
|
+
*/ function get() {
|
1586
1670
|
return true;
|
1587
1671
|
}
|
1588
1672
|
},
|
1589
1673
|
{
|
1590
|
-
/**
|
1674
|
+
/**
|
1675
|
+
* Return the offset in minutes for this zone at the specified timestamp.
|
1676
|
+
*
|
1677
|
+
* For fixed offset zones, this is constant and does not depend on a timestamp.
|
1678
|
+
* @override
|
1679
|
+
* @return {number}
|
1680
|
+
*/ key: "offset",
|
1591
1681
|
value: function offset() {
|
1592
1682
|
return this.fixed;
|
1593
1683
|
}
|
1594
1684
|
},
|
1595
1685
|
{
|
1596
|
-
/**
|
1686
|
+
/**
|
1687
|
+
* Return whether this Zone is equal to another zone (i.e. also fixed and same offset)
|
1688
|
+
* @override
|
1689
|
+
* @param {Zone} otherZone - the zone to compare
|
1690
|
+
* @return {boolean}
|
1691
|
+
*/ key: "equals",
|
1597
1692
|
value: function equals(otherZone) {
|
1598
1693
|
return otherZone.type === "fixed" && otherZone.fixed === this.fixed;
|
1599
1694
|
}
|
1600
1695
|
},
|
1601
1696
|
{
|
1602
1697
|
key: "isValid",
|
1603
|
-
get: /**
|
1698
|
+
get: /**
|
1699
|
+
* Return whether this Zone is valid:
|
1700
|
+
* All fixed offset zones are valid.
|
1701
|
+
* @override
|
1702
|
+
* @type {boolean}
|
1703
|
+
*/ function get() {
|
1604
1704
|
return true;
|
1605
1705
|
}
|
1606
1706
|
}
|
@@ -1737,6 +1837,146 @@ var singleton = null;
|
|
1737
1837
|
return new InvalidZone(input);
|
1738
1838
|
}
|
1739
1839
|
}
|
1840
|
+
var numberingSystems = {
|
1841
|
+
arab: "[٠-٩]",
|
1842
|
+
arabext: "[۰-۹]",
|
1843
|
+
bali: "[᭐-᭙]",
|
1844
|
+
beng: "[০-৯]",
|
1845
|
+
deva: "[०-९]",
|
1846
|
+
fullwide: "[0-9]",
|
1847
|
+
gujr: "[૦-૯]",
|
1848
|
+
hanidec: "[〇|一|二|三|四|五|六|七|八|九]",
|
1849
|
+
khmr: "[០-៩]",
|
1850
|
+
knda: "[೦-೯]",
|
1851
|
+
laoo: "[໐-໙]",
|
1852
|
+
limb: "[᥆-᥏]",
|
1853
|
+
mlym: "[൦-൯]",
|
1854
|
+
mong: "[᠐-᠙]",
|
1855
|
+
mymr: "[၀-၉]",
|
1856
|
+
orya: "[୦-୯]",
|
1857
|
+
tamldec: "[௦-௯]",
|
1858
|
+
telu: "[౦-౯]",
|
1859
|
+
thai: "[๐-๙]",
|
1860
|
+
tibt: "[༠-༩]",
|
1861
|
+
latn: "\\d"
|
1862
|
+
};
|
1863
|
+
var numberingSystemsUTF16 = {
|
1864
|
+
arab: [
|
1865
|
+
1632,
|
1866
|
+
1641
|
1867
|
+
],
|
1868
|
+
arabext: [
|
1869
|
+
1776,
|
1870
|
+
1785
|
1871
|
+
],
|
1872
|
+
bali: [
|
1873
|
+
6992,
|
1874
|
+
7001
|
1875
|
+
],
|
1876
|
+
beng: [
|
1877
|
+
2534,
|
1878
|
+
2543
|
1879
|
+
],
|
1880
|
+
deva: [
|
1881
|
+
2406,
|
1882
|
+
2415
|
1883
|
+
],
|
1884
|
+
fullwide: [
|
1885
|
+
65296,
|
1886
|
+
65303
|
1887
|
+
],
|
1888
|
+
gujr: [
|
1889
|
+
2790,
|
1890
|
+
2799
|
1891
|
+
],
|
1892
|
+
khmr: [
|
1893
|
+
6112,
|
1894
|
+
6121
|
1895
|
+
],
|
1896
|
+
knda: [
|
1897
|
+
3302,
|
1898
|
+
3311
|
1899
|
+
],
|
1900
|
+
laoo: [
|
1901
|
+
3792,
|
1902
|
+
3801
|
1903
|
+
],
|
1904
|
+
limb: [
|
1905
|
+
6470,
|
1906
|
+
6479
|
1907
|
+
],
|
1908
|
+
mlym: [
|
1909
|
+
3430,
|
1910
|
+
3439
|
1911
|
+
],
|
1912
|
+
mong: [
|
1913
|
+
6160,
|
1914
|
+
6169
|
1915
|
+
],
|
1916
|
+
mymr: [
|
1917
|
+
4160,
|
1918
|
+
4169
|
1919
|
+
],
|
1920
|
+
orya: [
|
1921
|
+
2918,
|
1922
|
+
2927
|
1923
|
+
],
|
1924
|
+
tamldec: [
|
1925
|
+
3046,
|
1926
|
+
3055
|
1927
|
+
],
|
1928
|
+
telu: [
|
1929
|
+
3174,
|
1930
|
+
3183
|
1931
|
+
],
|
1932
|
+
thai: [
|
1933
|
+
3664,
|
1934
|
+
3673
|
1935
|
+
],
|
1936
|
+
tibt: [
|
1937
|
+
3872,
|
1938
|
+
3881
|
1939
|
+
]
|
1940
|
+
};
|
1941
|
+
var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
|
1942
|
+
function parseDigits(str) {
|
1943
|
+
var value = parseInt(str, 10);
|
1944
|
+
if (isNaN(value)) {
|
1945
|
+
value = "";
|
1946
|
+
for(var i = 0; i < str.length; i++){
|
1947
|
+
var code = str.charCodeAt(i);
|
1948
|
+
if (str[i].search(numberingSystems.hanidec) !== -1) {
|
1949
|
+
value += hanidecChars.indexOf(str[i]);
|
1950
|
+
} else {
|
1951
|
+
for(var key in numberingSystemsUTF16){
|
1952
|
+
var _numberingSystemsUTF16_key = _sliced_to_array$1(numberingSystemsUTF16[key], 2), min = _numberingSystemsUTF16_key[0], max = _numberingSystemsUTF16_key[1];
|
1953
|
+
if (code >= min && code <= max) {
|
1954
|
+
value += code - min;
|
1955
|
+
}
|
1956
|
+
}
|
1957
|
+
}
|
1958
|
+
}
|
1959
|
+
return parseInt(value, 10);
|
1960
|
+
} else {
|
1961
|
+
return value;
|
1962
|
+
}
|
1963
|
+
}
|
1964
|
+
// cache of {numberingSystem: {append: regex}}
|
1965
|
+
var digitRegexCache = {};
|
1966
|
+
function resetDigitRegexCache() {
|
1967
|
+
digitRegexCache = {};
|
1968
|
+
}
|
1969
|
+
function digitRegex(param) {
|
1970
|
+
var numberingSystem = param.numberingSystem, append = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
1971
|
+
var ns = numberingSystem || "latn";
|
1972
|
+
if (!digitRegexCache[ns]) {
|
1973
|
+
digitRegexCache[ns] = {};
|
1974
|
+
}
|
1975
|
+
if (!digitRegexCache[ns][append]) {
|
1976
|
+
digitRegexCache[ns][append] = new RegExp("".concat(numberingSystems[ns]).concat(append));
|
1977
|
+
}
|
1978
|
+
return digitRegexCache[ns][append];
|
1979
|
+
}
|
1740
1980
|
var now = function() {
|
1741
1981
|
return Date.now();
|
1742
1982
|
}, defaultZone = "system", defaultLocale = null, defaultNumberingSystem = null, defaultOutputCalendar = null, twoDigitCutoffYear = 60, throwOnInvalid, defaultWeekSettings = null;
|
@@ -1852,16 +2092,17 @@ var now = function() {
|
|
1852
2092
|
{
|
1853
2093
|
key: "twoDigitCutoffYear",
|
1854
2094
|
get: /**
|
1855
|
-
* Get the cutoff year
|
2095
|
+
* 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.
|
1856
2096
|
* @type {number}
|
1857
2097
|
*/ function get() {
|
1858
2098
|
return twoDigitCutoffYear;
|
1859
2099
|
},
|
1860
2100
|
set: /**
|
1861
|
-
* Set the cutoff year
|
2101
|
+
* 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.
|
1862
2102
|
* @type {number}
|
1863
|
-
* @example Settings.twoDigitCutoffYear = 0 //
|
1864
|
-
* @example Settings.twoDigitCutoffYear =
|
2103
|
+
* @example Settings.twoDigitCutoffYear = 0 // all 'yy' are interpreted as 20th century
|
2104
|
+
* @example Settings.twoDigitCutoffYear = 99 // all 'yy' are interpreted as 21st century
|
2105
|
+
* @example Settings.twoDigitCutoffYear = 50 // '49' -> 2049; '50' -> 1950
|
1865
2106
|
* @example Settings.twoDigitCutoffYear = 1950 // interpreted as 50
|
1866
2107
|
* @example Settings.twoDigitCutoffYear = 2050 // ALSO interpreted as 50
|
1867
2108
|
*/ function set(cutoffYear) {
|
@@ -1891,6 +2132,8 @@ var now = function() {
|
|
1891
2132
|
*/ function resetCaches() {
|
1892
2133
|
Locale.resetCache();
|
1893
2134
|
IANAZone.resetCache();
|
2135
|
+
DateTime.resetCache();
|
2136
|
+
resetDigitRegexCache();
|
1894
2137
|
}
|
1895
2138
|
}
|
1896
2139
|
]);
|
@@ -2339,7 +2582,13 @@ function normalizeObject(obj, normalizer) {
|
|
2339
2582
|
}
|
2340
2583
|
return normalized;
|
2341
2584
|
}
|
2342
|
-
|
2585
|
+
/**
|
2586
|
+
* Returns the offset's value as a string
|
2587
|
+
* @param {number} ts - Epoch milliseconds for which to get the offset
|
2588
|
+
* @param {string} format - What style of offset to return.
|
2589
|
+
* Accepts 'narrow', 'short', or 'techie'. Returning '+6', '+06:00', or '+0600' respectively
|
2590
|
+
* @return {string}
|
2591
|
+
*/ function formatOffset(offset, format) {
|
2343
2592
|
var hours = Math.trunc(Math.abs(offset / 60)), minutes = Math.trunc(Math.abs(offset % 60)), sign = offset >= 0 ? "+" : "-";
|
2344
2593
|
switch(format){
|
2345
2594
|
case "short":
|
@@ -4781,7 +5030,7 @@ function validateStartEnd(start, end) {
|
|
4781
5030
|
},
|
4782
5031
|
{
|
4783
5032
|
/**
|
4784
|
-
*
|
5033
|
+
* 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.
|
4785
5034
|
* @param {Interval} other
|
4786
5035
|
* @return {boolean}
|
4787
5036
|
*/ key: "engulfs",
|
@@ -5554,134 +5803,6 @@ function diff(earlier, later, units, opts) {
|
|
5554
5803
|
return duration;
|
5555
5804
|
}
|
5556
5805
|
}
|
5557
|
-
var numberingSystems = {
|
5558
|
-
arab: "[٠-٩]",
|
5559
|
-
arabext: "[۰-۹]",
|
5560
|
-
bali: "[᭐-᭙]",
|
5561
|
-
beng: "[০-৯]",
|
5562
|
-
deva: "[०-९]",
|
5563
|
-
fullwide: "[0-9]",
|
5564
|
-
gujr: "[૦-૯]",
|
5565
|
-
hanidec: "[〇|一|二|三|四|五|六|七|八|九]",
|
5566
|
-
khmr: "[០-៩]",
|
5567
|
-
knda: "[೦-೯]",
|
5568
|
-
laoo: "[໐-໙]",
|
5569
|
-
limb: "[᥆-᥏]",
|
5570
|
-
mlym: "[൦-൯]",
|
5571
|
-
mong: "[᠐-᠙]",
|
5572
|
-
mymr: "[၀-၉]",
|
5573
|
-
orya: "[୦-୯]",
|
5574
|
-
tamldec: "[௦-௯]",
|
5575
|
-
telu: "[౦-౯]",
|
5576
|
-
thai: "[๐-๙]",
|
5577
|
-
tibt: "[༠-༩]",
|
5578
|
-
latn: "\\d"
|
5579
|
-
};
|
5580
|
-
var numberingSystemsUTF16 = {
|
5581
|
-
arab: [
|
5582
|
-
1632,
|
5583
|
-
1641
|
5584
|
-
],
|
5585
|
-
arabext: [
|
5586
|
-
1776,
|
5587
|
-
1785
|
5588
|
-
],
|
5589
|
-
bali: [
|
5590
|
-
6992,
|
5591
|
-
7001
|
5592
|
-
],
|
5593
|
-
beng: [
|
5594
|
-
2534,
|
5595
|
-
2543
|
5596
|
-
],
|
5597
|
-
deva: [
|
5598
|
-
2406,
|
5599
|
-
2415
|
5600
|
-
],
|
5601
|
-
fullwide: [
|
5602
|
-
65296,
|
5603
|
-
65303
|
5604
|
-
],
|
5605
|
-
gujr: [
|
5606
|
-
2790,
|
5607
|
-
2799
|
5608
|
-
],
|
5609
|
-
khmr: [
|
5610
|
-
6112,
|
5611
|
-
6121
|
5612
|
-
],
|
5613
|
-
knda: [
|
5614
|
-
3302,
|
5615
|
-
3311
|
5616
|
-
],
|
5617
|
-
laoo: [
|
5618
|
-
3792,
|
5619
|
-
3801
|
5620
|
-
],
|
5621
|
-
limb: [
|
5622
|
-
6470,
|
5623
|
-
6479
|
5624
|
-
],
|
5625
|
-
mlym: [
|
5626
|
-
3430,
|
5627
|
-
3439
|
5628
|
-
],
|
5629
|
-
mong: [
|
5630
|
-
6160,
|
5631
|
-
6169
|
5632
|
-
],
|
5633
|
-
mymr: [
|
5634
|
-
4160,
|
5635
|
-
4169
|
5636
|
-
],
|
5637
|
-
orya: [
|
5638
|
-
2918,
|
5639
|
-
2927
|
5640
|
-
],
|
5641
|
-
tamldec: [
|
5642
|
-
3046,
|
5643
|
-
3055
|
5644
|
-
],
|
5645
|
-
telu: [
|
5646
|
-
3174,
|
5647
|
-
3183
|
5648
|
-
],
|
5649
|
-
thai: [
|
5650
|
-
3664,
|
5651
|
-
3673
|
5652
|
-
],
|
5653
|
-
tibt: [
|
5654
|
-
3872,
|
5655
|
-
3881
|
5656
|
-
]
|
5657
|
-
};
|
5658
|
-
var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
|
5659
|
-
function parseDigits(str) {
|
5660
|
-
var value = parseInt(str, 10);
|
5661
|
-
if (isNaN(value)) {
|
5662
|
-
value = "";
|
5663
|
-
for(var i = 0; i < str.length; i++){
|
5664
|
-
var code = str.charCodeAt(i);
|
5665
|
-
if (str[i].search(numberingSystems.hanidec) !== -1) {
|
5666
|
-
value += hanidecChars.indexOf(str[i]);
|
5667
|
-
} else {
|
5668
|
-
for(var key in numberingSystemsUTF16){
|
5669
|
-
var _numberingSystemsUTF16_key = _sliced_to_array$1(numberingSystemsUTF16[key], 2), min = _numberingSystemsUTF16_key[0], max = _numberingSystemsUTF16_key[1];
|
5670
|
-
if (code >= min && code <= max) {
|
5671
|
-
value += code - min;
|
5672
|
-
}
|
5673
|
-
}
|
5674
|
-
}
|
5675
|
-
}
|
5676
|
-
return parseInt(value, 10);
|
5677
|
-
} else {
|
5678
|
-
return value;
|
5679
|
-
}
|
5680
|
-
}
|
5681
|
-
function digitRegex(param) {
|
5682
|
-
var numberingSystem = param.numberingSystem, append = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
5683
|
-
return new RegExp("".concat(numberingSystems[numberingSystem || "latn"]).concat(append));
|
5684
|
-
}
|
5685
5806
|
var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
|
5686
5807
|
function intUnit(regex) {
|
5687
5808
|
var post = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function(i) {
|
@@ -6105,38 +6226,74 @@ function expandMacroTokens(tokens, locale) {
|
|
6105
6226
|
}
|
6106
6227
|
/**
|
6107
6228
|
* @private
|
6108
|
-
*/
|
6109
|
-
|
6110
|
-
|
6111
|
-
|
6112
|
-
|
6113
|
-
|
6114
|
-
|
6115
|
-
|
6116
|
-
|
6117
|
-
|
6118
|
-
|
6119
|
-
};
|
6120
|
-
|
6121
|
-
|
6122
|
-
|
6123
|
-
|
6124
|
-
undefined
|
6125
|
-
], 3), result = _ref[0], zone = _ref[1], specificOffset = _ref[2];
|
6126
|
-
if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
|
6127
|
-
throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");
|
6229
|
+
*/ var TokenParser = /*#__PURE__*/ function() {
|
6230
|
+
function TokenParser(locale, format) {
|
6231
|
+
_class_call_check$3(this, TokenParser);
|
6232
|
+
this.locale = locale;
|
6233
|
+
this.format = format;
|
6234
|
+
this.tokens = expandMacroTokens(Formatter.parseFormat(format), locale);
|
6235
|
+
this.units = this.tokens.map(function(t) {
|
6236
|
+
return unitForToken(t, locale);
|
6237
|
+
});
|
6238
|
+
this.disqualifyingUnit = this.units.find(function(t) {
|
6239
|
+
return t.invalidReason;
|
6240
|
+
});
|
6241
|
+
if (!this.disqualifyingUnit) {
|
6242
|
+
var _buildRegex = _sliced_to_array$1(buildRegex(this.units), 2), regexString = _buildRegex[0], handlers = _buildRegex[1];
|
6243
|
+
this.regex = RegExp(regexString, "i");
|
6244
|
+
this.handlers = handlers;
|
6128
6245
|
}
|
6129
|
-
return {
|
6130
|
-
input: input,
|
6131
|
-
tokens: tokens,
|
6132
|
-
regex: regex,
|
6133
|
-
rawMatches: rawMatches,
|
6134
|
-
matches: matches,
|
6135
|
-
result: result,
|
6136
|
-
zone: zone,
|
6137
|
-
specificOffset: specificOffset
|
6138
|
-
};
|
6139
6246
|
}
|
6247
|
+
_create_class$2(TokenParser, [
|
6248
|
+
{
|
6249
|
+
key: "explainFromTokens",
|
6250
|
+
value: function explainFromTokens(input) {
|
6251
|
+
if (!this.isValid) {
|
6252
|
+
return {
|
6253
|
+
input: input,
|
6254
|
+
tokens: this.tokens,
|
6255
|
+
invalidReason: this.invalidReason
|
6256
|
+
};
|
6257
|
+
} else {
|
6258
|
+
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) : [
|
6259
|
+
null,
|
6260
|
+
null,
|
6261
|
+
undefined
|
6262
|
+
], 3), result = _ref[0], zone = _ref[1], specificOffset = _ref[2];
|
6263
|
+
if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
|
6264
|
+
throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");
|
6265
|
+
}
|
6266
|
+
return {
|
6267
|
+
input: input,
|
6268
|
+
tokens: this.tokens,
|
6269
|
+
regex: this.regex,
|
6270
|
+
rawMatches: rawMatches,
|
6271
|
+
matches: matches,
|
6272
|
+
result: result,
|
6273
|
+
zone: zone,
|
6274
|
+
specificOffset: specificOffset
|
6275
|
+
};
|
6276
|
+
}
|
6277
|
+
}
|
6278
|
+
},
|
6279
|
+
{
|
6280
|
+
key: "isValid",
|
6281
|
+
get: function get() {
|
6282
|
+
return !this.disqualifyingUnit;
|
6283
|
+
}
|
6284
|
+
},
|
6285
|
+
{
|
6286
|
+
key: "invalidReason",
|
6287
|
+
get: function get() {
|
6288
|
+
return this.disqualifyingUnit ? this.disqualifyingUnit.invalidReason : null;
|
6289
|
+
}
|
6290
|
+
}
|
6291
|
+
]);
|
6292
|
+
return TokenParser;
|
6293
|
+
}();
|
6294
|
+
function explainFromTokens(locale, input, format) {
|
6295
|
+
var parser = new TokenParser(locale, format);
|
6296
|
+
return parser.explainFromTokens(input);
|
6140
6297
|
}
|
6141
6298
|
function parseFromTokens(locale, input, format) {
|
6142
6299
|
var _explainFromTokens = explainFromTokens(locale, input, format), result = _explainFromTokens.result, zone = _explainFromTokens.zone, specificOffset = _explainFromTokens.specificOffset, invalidReason = _explainFromTokens.invalidReason;
|
@@ -6442,11 +6599,43 @@ function normalizeUnitWithLocalWeeks(unit) {
|
|
6442
6599
|
return normalizeUnit(unit);
|
6443
6600
|
}
|
6444
6601
|
}
|
6602
|
+
// cache offsets for zones based on the current timestamp when this function is
|
6603
|
+
// first called. When we are handling a datetime from components like (year,
|
6604
|
+
// month, day, hour) in a time zone, we need a guess about what the timezone
|
6605
|
+
// offset is so that we can convert into a UTC timestamp. One way is to find the
|
6606
|
+
// offset of now in the zone. The actual date may have a different offset (for
|
6607
|
+
// example, if we handle a date in June while we're in December in a zone that
|
6608
|
+
// observes DST), but we can check and adjust that.
|
6609
|
+
//
|
6610
|
+
// When handling many dates, calculating the offset for now every time is
|
6611
|
+
// expensive. It's just a guess, so we can cache the offset to use even if we
|
6612
|
+
// are right on a time change boundary (we'll just correct in the other
|
6613
|
+
// direction). Using a timestamp from first read is a slight optimization for
|
6614
|
+
// handling dates close to the current date, since those dates will usually be
|
6615
|
+
// in the same offset (we could set the timestamp statically, instead). We use a
|
6616
|
+
// single timestamp for all zones to make things a bit more predictable.
|
6617
|
+
//
|
6618
|
+
// This is safe for quickDT (used by local() and utc()) because we don't fill in
|
6619
|
+
// higher-order units from tsNow (as we do in fromObject, this requires that
|
6620
|
+
// offset is calculated from tsNow).
|
6621
|
+
function guessOffsetForZone(zone) {
|
6622
|
+
if (!zoneOffsetGuessCache[zone]) {
|
6623
|
+
if (zoneOffsetTs === undefined) {
|
6624
|
+
zoneOffsetTs = Settings.now();
|
6625
|
+
}
|
6626
|
+
zoneOffsetGuessCache[zone] = zone.offset(zoneOffsetTs);
|
6627
|
+
}
|
6628
|
+
return zoneOffsetGuessCache[zone];
|
6629
|
+
}
|
6445
6630
|
// this is a dumbed down version of fromObject() that runs about 60% faster
|
6446
6631
|
// but doesn't do any validation, makes a bunch of assumptions about what units
|
6447
6632
|
// are present, and so on.
|
6448
6633
|
function quickDT(obj, opts) {
|
6449
|
-
var zone = normalizeZone(opts.zone, Settings.defaultZone)
|
6634
|
+
var zone = normalizeZone(opts.zone, Settings.defaultZone);
|
6635
|
+
if (!zone.isValid) {
|
6636
|
+
return DateTime.invalid(unsupportedZone(zone));
|
6637
|
+
}
|
6638
|
+
var loc = Locale.fromObject(opts);
|
6450
6639
|
var ts, o;
|
6451
6640
|
// assume we have the higher-order units
|
6452
6641
|
if (!isUndefined(obj.year)) {
|
@@ -6476,11 +6665,11 @@ function quickDT(obj, opts) {
|
|
6476
6665
|
if (invalid) {
|
6477
6666
|
return DateTime.invalid(invalid);
|
6478
6667
|
}
|
6479
|
-
var offsetProvis = zone
|
6668
|
+
var offsetProvis = guessOffsetForZone(zone);
|
6480
6669
|
var ref;
|
6481
6670
|
ref = _sliced_to_array$1(objToTS(obj, offsetProvis, zone), 2), ts = ref[0], o = ref[1];
|
6482
6671
|
} else {
|
6483
|
-
ts =
|
6672
|
+
ts = Settings.now();
|
6484
6673
|
}
|
6485
6674
|
return new DateTime({
|
6486
6675
|
ts: ts,
|
@@ -6544,6 +6733,15 @@ function lastOpts(argList) {
|
|
6544
6733
|
args
|
6545
6734
|
];
|
6546
6735
|
}
|
6736
|
+
/**
|
6737
|
+
* Timestamp to use for cached zone offset guesses (exposed for test)
|
6738
|
+
*/ var zoneOffsetTs;
|
6739
|
+
/**
|
6740
|
+
* Cache for zone offset guesses (exposed for test).
|
6741
|
+
*
|
6742
|
+
* This optimizes quickDT via guessOffsetForZone to avoid repeated calls of
|
6743
|
+
* zone.offset().
|
6744
|
+
*/ var zoneOffsetGuessCache = {};
|
6547
6745
|
/**
|
6548
6746
|
* 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.
|
6549
6747
|
*
|
@@ -6581,7 +6779,9 @@ function lastOpts(argList) {
|
|
6581
6779
|
config.old.o
|
6582
6780
|
], c = ref[0], o = ref[1];
|
6583
6781
|
} else {
|
6584
|
-
|
6782
|
+
// If an offset has been passed and we have not been called from
|
6783
|
+
// clone(), we can trust it and avoid the offset calculation.
|
6784
|
+
var ot = isNumber(config.o) && !config.old ? config.o : zone.offset(this.ts);
|
6585
6785
|
c = tsToObj(this.ts, ot);
|
6586
6786
|
invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null;
|
6587
6787
|
c = invalid ? null : c;
|
@@ -7914,6 +8114,7 @@ function lastOpts(argList) {
|
|
7914
8114
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
7915
8115
|
* @param {string} [options.outputCalendar] - the output calendar to set on the resulting DateTime instance
|
7916
8116
|
* @param {string} [options.numberingSystem] - the numbering system to set on the resulting DateTime instance
|
8117
|
+
* @param {string} [options.weekSettings] - the week settings to set on the resulting DateTime instance
|
7917
8118
|
* @example DateTime.utc() //~> now
|
7918
8119
|
* @example DateTime.utc(2017) //~> 2017-01-01T00:00:00Z
|
7919
8120
|
* @example DateTime.utc(2017, 3) //~> 2017-03-01T00:00:00Z
|
@@ -7973,13 +8174,14 @@ function lastOpts(argList) {
|
|
7973
8174
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
7974
8175
|
* @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
7975
8176
|
* @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8177
|
+
* @param {string} options.weekSettings - the week settings to set on the resulting DateTime instance
|
7976
8178
|
* @return {DateTime}
|
7977
8179
|
*/ function fromMillis(milliseconds) {
|
7978
8180
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
7979
8181
|
if (!isNumber(milliseconds)) {
|
7980
8182
|
throw new InvalidArgumentError("fromMillis requires a numerical input, but received a ".concat(typeof milliseconds === "undefined" ? "undefined" : _type_of$2(milliseconds), " with value ").concat(milliseconds));
|
7981
8183
|
} else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
|
7982
|
-
// this isn't perfect because
|
8184
|
+
// this isn't perfect because we can still end up out of range because of additional shifting, but it's a start
|
7983
8185
|
return DateTime.invalid("Timestamp out of range");
|
7984
8186
|
} else {
|
7985
8187
|
return new DateTime({
|
@@ -8000,6 +8202,7 @@ function lastOpts(argList) {
|
|
8000
8202
|
* @param {string} [options.locale] - a locale to set on the resulting DateTime instance
|
8001
8203
|
* @param {string} options.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8002
8204
|
* @param {string} options.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8205
|
+
* @param {string} options.weekSettings - the week settings to set on the resulting DateTime instance
|
8003
8206
|
* @return {DateTime}
|
8004
8207
|
*/ function fromSeconds(seconds) {
|
8005
8208
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
@@ -8038,6 +8241,7 @@ function lastOpts(argList) {
|
|
8038
8241
|
* @param {string} [opts.locale='system\'s locale'] - a locale to set on the resulting DateTime instance
|
8039
8242
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8040
8243
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8244
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8041
8245
|
* @example DateTime.fromObject({ year: 1982, month: 5, day: 25}).toISODate() //=> '1982-05-25'
|
8042
8246
|
* @example DateTime.fromObject({ year: 1982 }).toISODate() //=> '1982-01-01'
|
8043
8247
|
* @example DateTime.fromObject({ hour: 10, minute: 26, second: 6 }) //~> today at 10:26:06
|
@@ -8129,6 +8333,9 @@ function lastOpts(argList) {
|
|
8129
8333
|
if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) {
|
8130
8334
|
return DateTime.invalid("mismatched weekday", "you can't specify both a weekday of ".concat(normalized.weekday, " and a date of ").concat(inst.toISO()));
|
8131
8335
|
}
|
8336
|
+
if (!inst.isValid) {
|
8337
|
+
return DateTime.invalid(inst.invalid);
|
8338
|
+
}
|
8132
8339
|
return inst;
|
8133
8340
|
}
|
8134
8341
|
},
|
@@ -8143,6 +8350,7 @@ function lastOpts(argList) {
|
|
8143
8350
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
8144
8351
|
* @param {string} [opts.outputCalendar] - the output calendar to set on the resulting DateTime instance
|
8145
8352
|
* @param {string} [opts.numberingSystem] - the numbering system to set on the resulting DateTime instance
|
8353
|
+
* @param {string} [opts.weekSettings] - the week settings to set on the resulting DateTime instance
|
8146
8354
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123')
|
8147
8355
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00')
|
8148
8356
|
* @example DateTime.fromISO('2016-05-25T09:08:34.123+06:00', {setZone: true})
|
@@ -8166,6 +8374,7 @@ function lastOpts(argList) {
|
|
8166
8374
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
8167
8375
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8168
8376
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8377
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8169
8378
|
* @example DateTime.fromRFC2822('25 Nov 2016 13:23:12 GMT')
|
8170
8379
|
* @example DateTime.fromRFC2822('Fri, 25 Nov 2016 13:23:12 +0600')
|
8171
8380
|
* @example DateTime.fromRFC2822('25 Nov 2016 13:23 Z')
|
@@ -8188,6 +8397,7 @@ function lastOpts(argList) {
|
|
8188
8397
|
* @param {string} [opts.locale='system's locale'] - a locale to set on the resulting DateTime instance
|
8189
8398
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8190
8399
|
* @param {string} opts.numberingSystem - the numbering system to set on the resulting DateTime instance
|
8400
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8191
8401
|
* @example DateTime.fromHTTP('Sun, 06 Nov 1994 08:49:37 GMT')
|
8192
8402
|
* @example DateTime.fromHTTP('Sunday, 06-Nov-94 08:49:37 GMT')
|
8193
8403
|
* @example DateTime.fromHTTP('Sun Nov 6 08:49:37 1994')
|
@@ -8210,6 +8420,7 @@ function lastOpts(argList) {
|
|
8210
8420
|
* @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
|
8211
8421
|
* @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
|
8212
8422
|
* @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
|
8423
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8213
8424
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8214
8425
|
* @return {DateTime}
|
8215
8426
|
*/ function fromFormat(text, fmt) {
|
@@ -8249,6 +8460,7 @@ function lastOpts(argList) {
|
|
8249
8460
|
* @param {boolean} [opts.setZone=false] - override the zone with a zone specified in the string itself, if it specifies one
|
8250
8461
|
* @param {string} [opts.locale='en-US'] - a locale string to use when parsing. Will also set the DateTime to this locale
|
8251
8462
|
* @param {string} opts.numberingSystem - the numbering system to use when parsing. Will also set the resulting DateTime to this numbering system
|
8463
|
+
* @param {string} opts.weekSettings - the week settings to set on the resulting DateTime instance
|
8252
8464
|
* @param {string} opts.outputCalendar - the output calendar to set on the resulting DateTime instance
|
8253
8465
|
* @example DateTime.fromSQL('2017-05-15')
|
8254
8466
|
* @example DateTime.fromSQL('2017-05-15 09:12:34')
|
@@ -8328,6 +8540,13 @@ function lastOpts(argList) {
|
|
8328
8540
|
}).join("");
|
8329
8541
|
}
|
8330
8542
|
},
|
8543
|
+
{
|
8544
|
+
key: "resetCache",
|
8545
|
+
value: function resetCache() {
|
8546
|
+
zoneOffsetTs = undefined;
|
8547
|
+
zoneOffsetGuessCache = {};
|
8548
|
+
}
|
8549
|
+
},
|
8331
8550
|
{
|
8332
8551
|
key: "min",
|
8333
8552
|
value: /**
|
@@ -8392,6 +8611,61 @@ function lastOpts(argList) {
|
|
8392
8611
|
return DateTime.fromFormatExplain(text, fmt, options);
|
8393
8612
|
}
|
8394
8613
|
},
|
8614
|
+
{
|
8615
|
+
key: "buildFormatParser",
|
8616
|
+
value: /**
|
8617
|
+
* Build a parser for `fmt` using the given locale. This parser can be passed
|
8618
|
+
* to {@link DateTime.fromFormatParser} to a parse a date in this format. This
|
8619
|
+
* can be used to optimize cases where many dates need to be parsed in a
|
8620
|
+
* specific format.
|
8621
|
+
*
|
8622
|
+
* @param {String} fmt - the format the string is expected to be in (see
|
8623
|
+
* description)
|
8624
|
+
* @param {Object} options - options used to set locale and numberingSystem
|
8625
|
+
* for parser
|
8626
|
+
* @returns {TokenParser} - opaque object to be used
|
8627
|
+
*/ function buildFormatParser(fmt) {
|
8628
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
8629
|
+
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({
|
8630
|
+
locale: locale,
|
8631
|
+
numberingSystem: numberingSystem,
|
8632
|
+
defaultToEN: true
|
8633
|
+
});
|
8634
|
+
return new TokenParser(localeToUse, fmt);
|
8635
|
+
}
|
8636
|
+
},
|
8637
|
+
{
|
8638
|
+
key: "fromFormatParser",
|
8639
|
+
value: /**
|
8640
|
+
* Create a DateTime from an input string and format parser.
|
8641
|
+
*
|
8642
|
+
* The format parser must have been created with the same locale as this call.
|
8643
|
+
*
|
8644
|
+
* @param {String} text - the string to parse
|
8645
|
+
* @param {TokenParser} formatParser - parser from {@link DateTime.buildFormatParser}
|
8646
|
+
* @param {Object} opts - options taken by fromFormat()
|
8647
|
+
* @returns {DateTime}
|
8648
|
+
*/ function fromFormatParser(text, formatParser) {
|
8649
|
+
var opts = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
8650
|
+
if (isUndefined(text) || isUndefined(formatParser)) {
|
8651
|
+
throw new InvalidArgumentError("fromFormatParser requires an input string and a format parser");
|
8652
|
+
}
|
8653
|
+
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({
|
8654
|
+
locale: locale,
|
8655
|
+
numberingSystem: numberingSystem,
|
8656
|
+
defaultToEN: true
|
8657
|
+
});
|
8658
|
+
if (!localeToUse.equals(formatParser.locale)) {
|
8659
|
+
throw new InvalidArgumentError("fromFormatParser called with a locale of ".concat(localeToUse, ", ") + "but the format parser was created for ".concat(formatParser.locale));
|
8660
|
+
}
|
8661
|
+
var _formatParser_explainFromTokens = formatParser.explainFromTokens(text), result = _formatParser_explainFromTokens.result, zone = _formatParser_explainFromTokens.zone, specificOffset = _formatParser_explainFromTokens.specificOffset, invalidReason = _formatParser_explainFromTokens.invalidReason;
|
8662
|
+
if (invalidReason) {
|
8663
|
+
return DateTime.invalid(invalidReason);
|
8664
|
+
} else {
|
8665
|
+
return parseDataToDateTime(result, zone, opts, "format ".concat(formatParser.format), text, specificOffset);
|
8666
|
+
}
|
8667
|
+
}
|
8668
|
+
},
|
8395
8669
|
{
|
8396
8670
|
key: "DATE_SHORT",
|
8397
8671
|
get: // FORMAT PRESETS
|
@@ -8607,7 +8881,7 @@ function lastOpts(argList) {
|
|
8607
8881
|
throw new InvalidArgumentError("Unknown datetime argument: ".concat(dateTimeish, ", of type ").concat(typeof dateTimeish === "undefined" ? "undefined" : _type_of$2(dateTimeish)));
|
8608
8882
|
}
|
8609
8883
|
}
|
8610
|
-
var VERSION = "3.
|
8884
|
+
var VERSION = "3.5.0";
|
8611
8885
|
luxon.DateTime = DateTime;
|
8612
8886
|
luxon.Duration = Duration;
|
8613
8887
|
luxon.FixedOffsetZone = FixedOffsetZone;
|