@bbn/bbn 2.0.43 → 2.0.44
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/bbn.js +1 -1
- package/dist/bbn.js.map +1 -1
- package/dist/dt/functions/parse.js +20 -5
- package/package.json +1 -1
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import buildLocaleFromIntl from './buildLocaleFromIntl.js';
|
|
2
|
+
const lc = function (str, localeCode) {
|
|
3
|
+
try {
|
|
4
|
+
return localeCode ? str.toLocaleLowerCase(localeCode) : str.toLowerCase();
|
|
5
|
+
}
|
|
6
|
+
catch (_a) {
|
|
7
|
+
return str.toLowerCase();
|
|
8
|
+
}
|
|
9
|
+
};
|
|
2
10
|
export default function parse(input, format, locale) {
|
|
3
|
-
var _a, _b, _c, _d;
|
|
11
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4
12
|
buildLocaleFromIntl();
|
|
5
13
|
const TemporalAny = globalThis.Temporal;
|
|
6
14
|
if (!TemporalAny) {
|
|
@@ -13,6 +21,9 @@ export default function parse(input, format, locale) {
|
|
|
13
21
|
weekdaysLong: (_c = locale === null || locale === void 0 ? void 0 : locale.weekdaysLong) !== null && _c !== void 0 ? _c : bbn.dt.locales.weekdaysLong,
|
|
14
22
|
weekdaysShort: (_d = locale === null || locale === void 0 ? void 0 : locale.weekdaysShort) !== null && _d !== void 0 ? _d : bbn.dt.locales.weekdaysShort
|
|
15
23
|
};
|
|
24
|
+
const localeCode = ((bbn === null || bbn === void 0 ? void 0 : bbn.env) && ((_e = bbn.env) === null || _e === void 0 ? void 0 : _e.lang)) ||
|
|
25
|
+
((bbn === null || bbn === void 0 ? void 0 : bbn.dt) && ((_f = bbn.dt) === null || _f === void 0 ? void 0 : _f.locale)) ||
|
|
26
|
+
Intl.DateTimeFormat().resolvedOptions().locale;
|
|
16
27
|
const escapeRegex = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
17
28
|
const makeTokenSpecs = () => [
|
|
18
29
|
// Years
|
|
@@ -46,8 +57,9 @@ export default function parse(input, format, locale) {
|
|
|
46
57
|
token: 'MMMM',
|
|
47
58
|
regex: '[^\\d\\s]+',
|
|
48
59
|
apply: (v, ctx) => {
|
|
60
|
+
const val = lc(v, localeCode);
|
|
49
61
|
const idx = loc.monthsLong
|
|
50
|
-
.findIndex((m) => m
|
|
62
|
+
.findIndex((m) => lc(m, localeCode) === val);
|
|
51
63
|
if (idx === -1) {
|
|
52
64
|
throw new Error('Invalid month name: ' + v);
|
|
53
65
|
}
|
|
@@ -59,8 +71,9 @@ export default function parse(input, format, locale) {
|
|
|
59
71
|
token: 'MMM',
|
|
60
72
|
regex: '[^\\d\\s]+',
|
|
61
73
|
apply: (v, ctx) => {
|
|
74
|
+
const val = lc(v, localeCode);
|
|
62
75
|
const idx = loc.monthsShort
|
|
63
|
-
.findIndex((m) => m
|
|
76
|
+
.findIndex((m) => lc(m, localeCode) === val);
|
|
64
77
|
if (idx === -1) {
|
|
65
78
|
throw new Error('Invalid short month name: ' + v);
|
|
66
79
|
}
|
|
@@ -159,8 +172,9 @@ export default function parse(input, format, locale) {
|
|
|
159
172
|
token: 'dddd',
|
|
160
173
|
regex: '[^\\d\\s]+',
|
|
161
174
|
apply: (v, ctx) => {
|
|
175
|
+
const val = lc(v, localeCode);
|
|
162
176
|
const idx = loc.weekdaysLong
|
|
163
|
-
.findIndex((w) => w
|
|
177
|
+
.findIndex((w) => lc(w, localeCode) === val);
|
|
164
178
|
if (idx === -1) {
|
|
165
179
|
throw new Error('Invalid weekday name: ' + v);
|
|
166
180
|
}
|
|
@@ -171,8 +185,9 @@ export default function parse(input, format, locale) {
|
|
|
171
185
|
token: 'ddd',
|
|
172
186
|
regex: '[^\\d\\s]+',
|
|
173
187
|
apply: (v, ctx) => {
|
|
188
|
+
const val = lc(v, localeCode);
|
|
174
189
|
const idx = loc.weekdaysShort
|
|
175
|
-
.findIndex((w) => w
|
|
190
|
+
.findIndex((w) => lc(w, localeCode) === val);
|
|
176
191
|
if (idx === -1) {
|
|
177
192
|
throw new Error('Invalid short weekday name: ' + v);
|
|
178
193
|
}
|