temporal-fmt 0.9.80 → 0.9.81
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/README.md +302 -490
- package/dist/chunk-6FPOCDZV.js +129 -0
- package/dist/chunk-6FPOCDZV.js.map +1 -0
- package/dist/{chunk-HGRT37LT.js → chunk-ACGCGXP5.js} +3 -3
- package/dist/{chunk-WP7TBCTT.js → chunk-E4DD23HH.js} +8 -8
- package/dist/{chunk-5KP5H7X2.js → chunk-EEPLAE3H.js} +5 -3
- package/dist/{chunk-DMJWJTFY.js → chunk-EXIJZ4JG.js} +2 -2
- package/dist/{chunk-Z245NHDT.js → chunk-GRBQ5FRO.js} +5 -5
- package/dist/{chunk-WEVNKOQA.js → chunk-TDQYKYVJ.js} +5 -5
- package/dist/{chunk-LHR5PCP4.js → chunk-UYKKGBZ3.js} +7 -7
- package/dist/{chunk-64UB3WDT.js → chunk-YQGUTK4E.js} +4 -4
- package/dist/duration.js +3 -3
- package/dist/format.js +4 -4
- package/dist/index.cjs +138 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +107 -86
- package/dist/index.js.map +1 -1
- package/dist/interval.js +7 -7
- package/dist/legacy/index.d.cts +23 -0
- package/dist/legacy/index.d.ts +23 -0
- package/dist/legacy/matchesFormat.d.cts +6 -0
- package/dist/legacy/matchesFormat.d.ts +6 -0
- package/dist/legacy.cjs +2153 -0
- package/dist/legacy.cjs.map +1 -0
- package/dist/legacy.d.cts +1 -0
- package/dist/legacy.d.ts +1 -0
- package/dist/legacy.js +31 -0
- package/dist/legacy.js.map +1 -0
- package/dist/parse.js +4 -4
- package/dist/relativeTime.js +4 -4
- package/dist/timezone.js +2 -2
- package/legacy.d.cts +1 -0
- package/legacy.d.ts +1 -0
- package/package.json +13 -1
- /package/dist/{chunk-HGRT37LT.js.map → chunk-ACGCGXP5.js.map} +0 -0
- /package/dist/{chunk-WP7TBCTT.js.map → chunk-E4DD23HH.js.map} +0 -0
- /package/dist/{chunk-5KP5H7X2.js.map → chunk-EEPLAE3H.js.map} +0 -0
- /package/dist/{chunk-DMJWJTFY.js.map → chunk-EXIJZ4JG.js.map} +0 -0
- /package/dist/{chunk-Z245NHDT.js.map → chunk-GRBQ5FRO.js.map} +0 -0
- /package/dist/{chunk-WEVNKOQA.js.map → chunk-TDQYKYVJ.js.map} +0 -0
- /package/dist/{chunk-LHR5PCP4.js.map → chunk-UYKKGBZ3.js.map} +0 -0
- /package/dist/{chunk-64UB3WDT.js.map → chunk-YQGUTK4E.js.map} +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compileFormat,
|
|
3
|
+
format,
|
|
4
|
+
formatToParts
|
|
5
|
+
} from "./chunk-ACGCGXP5.js";
|
|
6
|
+
import {
|
|
7
|
+
buildCapturingPattern,
|
|
8
|
+
compileParser,
|
|
9
|
+
enumerateValidSplits,
|
|
10
|
+
parse,
|
|
11
|
+
parseToParts,
|
|
12
|
+
safeParse,
|
|
13
|
+
tryParse
|
|
14
|
+
} from "./chunk-EEPLAE3H.js";
|
|
15
|
+
import {
|
|
16
|
+
tokenize
|
|
17
|
+
} from "./chunk-EXIJZ4JG.js";
|
|
18
|
+
import {
|
|
19
|
+
DEFAULT_LOCALE
|
|
20
|
+
} from "./chunk-GRBQ5FRO.js";
|
|
21
|
+
import {
|
|
22
|
+
MAX_FORMAT_LENGTH
|
|
23
|
+
} from "./chunk-SOPTTXUI.js";
|
|
24
|
+
import {
|
|
25
|
+
TemporalFmtError
|
|
26
|
+
} from "./chunk-QRLQ7RR7.js";
|
|
27
|
+
|
|
28
|
+
// src/legacy/matchesFormat.ts
|
|
29
|
+
var patternCache = /* @__PURE__ */ new Map();
|
|
30
|
+
var MAX_CACHE_SIZE = 500;
|
|
31
|
+
function getPattern(formatStr, locale) {
|
|
32
|
+
const key = locale + "\0" + formatStr;
|
|
33
|
+
const cached = patternCache.get(key);
|
|
34
|
+
if (cached) return cached;
|
|
35
|
+
if (patternCache.size >= MAX_CACHE_SIZE) {
|
|
36
|
+
const oldestKey = patternCache.keys().next().value;
|
|
37
|
+
if (oldestKey !== void 0) patternCache.delete(oldestKey);
|
|
38
|
+
}
|
|
39
|
+
const pattern = buildCapturingPattern(tokenize(formatStr), locale);
|
|
40
|
+
patternCache.set(key, pattern);
|
|
41
|
+
return pattern;
|
|
42
|
+
}
|
|
43
|
+
function matchesFormat(formatStr, input, options = {}) {
|
|
44
|
+
try {
|
|
45
|
+
if (formatStr.length > MAX_FORMAT_LENGTH) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters (got ${formatStr.length}).`
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
const locale = options.locale ?? DEFAULT_LOCALE;
|
|
51
|
+
const pattern = getPattern(formatStr, locale);
|
|
52
|
+
const match = pattern.regex.exec(input);
|
|
53
|
+
if (!match) return false;
|
|
54
|
+
for (const run of pattern.ambiguousRuns) {
|
|
55
|
+
const range = match.indices?.groups?.[run.groupName];
|
|
56
|
+
if (!range || enumerateValidSplits(input.slice(range[0], range[1]), run.tokens).length === 0) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
} catch (error) {
|
|
62
|
+
if (error instanceof TemporalFmtError) throw new Error(error.message);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/legacy/index.ts
|
|
68
|
+
function withLegacyErrors(operation) {
|
|
69
|
+
try {
|
|
70
|
+
return operation();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
if (error instanceof TemporalFmtError) {
|
|
73
|
+
throw new Error(error.message);
|
|
74
|
+
}
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function toLegacySafeParseResult(result) {
|
|
79
|
+
return result.ok ? result : { ok: false, error: new Error(result.error.message) };
|
|
80
|
+
}
|
|
81
|
+
function format2(temporal, formatStr, options = {}) {
|
|
82
|
+
return withLegacyErrors(() => format(temporal, formatStr, options));
|
|
83
|
+
}
|
|
84
|
+
function formatToParts2(temporal, formatStr, options = {}) {
|
|
85
|
+
return withLegacyErrors(() => formatToParts(temporal, formatStr, options));
|
|
86
|
+
}
|
|
87
|
+
function compileFormat2(formatStr) {
|
|
88
|
+
const compiled = withLegacyErrors(() => compileFormat(formatStr));
|
|
89
|
+
return {
|
|
90
|
+
...compiled,
|
|
91
|
+
format: (temporal, options) => withLegacyErrors(() => compiled.format(temporal, options)),
|
|
92
|
+
formatToParts: (temporal, options) => withLegacyErrors(() => compiled.formatToParts(temporal, options))
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function parse2(formatStr, input, options = {}) {
|
|
96
|
+
return withLegacyErrors(() => parse(formatStr, input, options));
|
|
97
|
+
}
|
|
98
|
+
function safeParse2(formatStr, input, options = {}) {
|
|
99
|
+
return toLegacySafeParseResult(safeParse(formatStr, input, options));
|
|
100
|
+
}
|
|
101
|
+
function tryParse2(formatStr, input, options = {}) {
|
|
102
|
+
return tryParse(formatStr, input, options);
|
|
103
|
+
}
|
|
104
|
+
function parseToParts2(formatStr, input, options = {}) {
|
|
105
|
+
return withLegacyErrors(() => parseToParts(formatStr, input, options));
|
|
106
|
+
}
|
|
107
|
+
function compileParser2(formatStr, options = {}) {
|
|
108
|
+
const compiled = withLegacyErrors(() => compileParser(formatStr, options));
|
|
109
|
+
return {
|
|
110
|
+
...compiled,
|
|
111
|
+
parse: (input, callOptions) => withLegacyErrors(() => compiled.parse(input, callOptions)),
|
|
112
|
+
safeParse: (input, callOptions) => toLegacySafeParseResult(compiled.safeParse(input, callOptions)),
|
|
113
|
+
tryParse: (input, callOptions) => compiled.tryParse(input, callOptions),
|
|
114
|
+
parseToParts: (input, callOptions) => withLegacyErrors(() => compiled.parseToParts(input, callOptions))
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export {
|
|
119
|
+
matchesFormat,
|
|
120
|
+
format2 as format,
|
|
121
|
+
formatToParts2 as formatToParts,
|
|
122
|
+
compileFormat2 as compileFormat,
|
|
123
|
+
parse2 as parse,
|
|
124
|
+
safeParse2 as safeParse,
|
|
125
|
+
tryParse2 as tryParse,
|
|
126
|
+
parseToParts2 as parseToParts,
|
|
127
|
+
compileParser2 as compileParser
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=chunk-6FPOCDZV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/legacy/matchesFormat.ts","../src/legacy/index.ts"],"sourcesContent":["/*\n * Copyright 2026 DirazCoder\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DEFAULT_LOCALE, type FormatOptions } from '../tokens.js';\nimport { tokenize } from '../tokenize.js';\nimport { buildCapturingPattern, type CapturingPattern } from '../parsePattern.js';\nimport { MAX_FORMAT_LENGTH } from '../constants.js';\nimport { TemporalFmtError } from '../errors.js';\nimport { enumerateValidSplits } from '../pattern.js';\n\nconst patternCache = new Map<string, CapturingPattern>();\nconst MAX_CACHE_SIZE = 500;\n\nfunction getPattern(formatStr: string, locale: string) {\n const key = locale + '\\0' + formatStr;\n const cached = patternCache.get(key);\n if (cached) return cached;\n\n if (patternCache.size >= MAX_CACHE_SIZE) {\n const oldestKey = patternCache.keys().next().value;\n if (oldestKey !== undefined) patternCache.delete(oldestKey);\n }\n\n const pattern = buildCapturingPattern(tokenize(formatStr), locale);\n patternCache.set(key, pattern);\n return pattern;\n}\n\n/**\n * Checks whether `input` could plausibly be output from `format()` for the\n * given format. It checks shape and locale vocabulary, not date validity.\n */\nexport function matchesFormat(formatStr: string, input: string, options: FormatOptions = {}): boolean {\n try {\n if (formatStr.length > MAX_FORMAT_LENGTH) {\n throw new Error(\n `temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters ` +\n `(got ${formatStr.length}).`,\n );\n }\n const locale = options.locale ?? DEFAULT_LOCALE;\n const pattern = getPattern(formatStr, locale);\n const match = pattern.regex.exec(input);\n if (!match) return false;\n\n for (const run of pattern.ambiguousRuns) {\n const range = match.indices?.groups?.[run.groupName];\n if (!range || enumerateValidSplits(input.slice(range[0], range[1]), run.tokens).length === 0) {\n return false;\n }\n }\n return true;\n } catch (error) {\n if (error instanceof TemporalFmtError) throw new Error(error.message);\n throw error;\n }\n}\n","/*\n * Copyright 2026 DirazCoder\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n format as typedFormat,\n formatToParts as typedFormatToParts,\n compileFormat as typedCompileFormat,\n type CompiledFormat,\n type FormattedPart,\n} from '../format.js';\nimport {\n parse as typedParse,\n safeParse as typedSafeParse,\n tryParse as typedTryParse,\n parseToParts as typedParseToParts,\n compileParser as typedCompileParser,\n type CompiledParser,\n type ParsedPart,\n} from '../parse.js';\nimport type { TemporalLike } from '../tokens.js';\nimport type { NumberingFormatOptions, NumberingParseOptions } from '../numbering.js';\nimport { TemporalFmtError } from '../errors.js';\n\nexport type LegacySafeParseResult =\n | { ok: true; value: unknown }\n | { ok: false; error: Error };\n\nexport type LegacyCompiledParser = Omit<CompiledParser, 'safeParse'> & {\n safeParse(input: string, options?: NumberingParseOptions): LegacySafeParseResult;\n};\n\nfunction withLegacyErrors<T>(operation: () => T): T {\n try {\n return operation();\n } catch (error) {\n if (error instanceof TemporalFmtError) {\n throw new Error(error.message);\n }\n throw error;\n }\n}\n\nfunction toLegacySafeParseResult(result: ReturnType<typeof typedSafeParse>): LegacySafeParseResult {\n return result.ok\n ? result\n : { ok: false, error: new Error(result.error.message) };\n}\n\nexport function format(\n temporal: TemporalLike,\n formatStr: string,\n options: NumberingFormatOptions = {},\n): string {\n return withLegacyErrors(() => typedFormat(temporal, formatStr, options));\n}\n\nexport function formatToParts(\n temporal: TemporalLike,\n formatStr: string,\n options: NumberingFormatOptions = {},\n): FormattedPart[] {\n return withLegacyErrors(() => typedFormatToParts(temporal, formatStr, options));\n}\n\nexport function compileFormat(formatStr: string): CompiledFormat {\n const compiled = withLegacyErrors(() => typedCompileFormat(formatStr));\n return {\n ...compiled,\n format: (temporal, options) => withLegacyErrors(() => compiled.format(temporal, options)),\n formatToParts: (temporal, options) => withLegacyErrors(() => compiled.formatToParts(temporal, options)),\n };\n}\n\nexport function parse(formatStr: string, input: string, options: NumberingParseOptions = {}): unknown | undefined {\n return withLegacyErrors(() => typedParse(formatStr, input, options));\n}\n\nexport function safeParse(\n formatStr: string,\n input: string,\n options: NumberingParseOptions = {},\n): LegacySafeParseResult {\n return toLegacySafeParseResult(typedSafeParse(formatStr, input, options));\n}\n\nexport function tryParse(formatStr: string, input: string, options: NumberingParseOptions = {}): unknown | undefined {\n return typedTryParse(formatStr, input, options);\n}\n\nexport function parseToParts(\n formatStr: string,\n input: string,\n options: NumberingParseOptions = {},\n): ParsedPart[] {\n return withLegacyErrors(() => typedParseToParts(formatStr, input, options));\n}\n\nexport function compileParser(formatStr: string, options: NumberingParseOptions = {}): LegacyCompiledParser {\n const compiled = withLegacyErrors(() => typedCompileParser(formatStr, options));\n return {\n ...compiled,\n parse: (input, callOptions) => withLegacyErrors(() => compiled.parse(input, callOptions)),\n safeParse: (input, callOptions) => toLegacySafeParseResult(compiled.safeParse(input, callOptions)),\n tryParse: (input, callOptions) => compiled.tryParse(input, callOptions),\n parseToParts: (input, callOptions) => withLegacyErrors(() => compiled.parseToParts(input, callOptions)),\n };\n}\n\nexport { matchesFormat } from './matchesFormat.js';\n"],"mappings":"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","names":["format","formatToParts","compileFormat","parse","safeParse","tryParse","parseToParts","compileParser"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyNumbering,
|
|
3
3
|
tokenize
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EXIJZ4JG.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_LOCALE,
|
|
7
7
|
TOKENS
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GRBQ5FRO.js";
|
|
9
9
|
import {
|
|
10
10
|
MAX_FORMAT_LENGTH
|
|
11
11
|
} from "./chunk-SOPTTXUI.js";
|
|
@@ -189,4 +189,4 @@ export {
|
|
|
189
189
|
_getPieces,
|
|
190
190
|
_handlerFor
|
|
191
191
|
};
|
|
192
|
-
//# sourceMappingURL=chunk-
|
|
192
|
+
//# sourceMappingURL=chunk-ACGCGXP5.js.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
format,
|
|
3
|
-
formatToParts
|
|
4
|
-
} from "./chunk-HGRT37LT.js";
|
|
5
|
-
import {
|
|
6
|
-
normalizeLocaleTag
|
|
7
|
-
} from "./chunk-QRLQ7RR7.js";
|
|
8
1
|
import {
|
|
9
2
|
compare
|
|
10
3
|
} from "./chunk-UGYSEYUQ.js";
|
|
11
4
|
import {
|
|
12
5
|
asDateFieldView
|
|
13
6
|
} from "./chunk-KEPIXQK7.js";
|
|
7
|
+
import {
|
|
8
|
+
format,
|
|
9
|
+
formatToParts
|
|
10
|
+
} from "./chunk-ACGCGXP5.js";
|
|
14
11
|
import {
|
|
15
12
|
daysFromCivil
|
|
16
13
|
} from "./chunk-BLZDBPSV.js";
|
|
14
|
+
import {
|
|
15
|
+
normalizeLocaleTag
|
|
16
|
+
} from "./chunk-QRLQ7RR7.js";
|
|
17
17
|
|
|
18
18
|
// src/interval.ts
|
|
19
19
|
function interval(start, end, bounds = "closed") {
|
|
@@ -238,4 +238,4 @@ export {
|
|
|
238
238
|
formatRange,
|
|
239
239
|
formatRangeToParts
|
|
240
240
|
};
|
|
241
|
-
//# sourceMappingURL=chunk-
|
|
241
|
+
//# sourceMappingURL=chunk-E4DD23HH.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyParseNumbering,
|
|
3
3
|
tokenize
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EXIJZ4JG.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_LOCALE
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GRBQ5FRO.js";
|
|
8
8
|
import {
|
|
9
9
|
getTemporal
|
|
10
10
|
} from "./chunk-DFWTCRS3.js";
|
|
@@ -975,10 +975,12 @@ function compileParser(formatStr, options = {}) {
|
|
|
975
975
|
export {
|
|
976
976
|
FORMAT_ONLY_TOKENS,
|
|
977
977
|
UNPADDED_NUMERIC_TOKENS,
|
|
978
|
+
enumerateValidSplits,
|
|
979
|
+
buildCapturingPattern,
|
|
978
980
|
parse,
|
|
979
981
|
safeParse,
|
|
980
982
|
tryParse,
|
|
981
983
|
parseToParts,
|
|
982
984
|
compileParser
|
|
983
985
|
};
|
|
984
|
-
//# sourceMappingURL=chunk-
|
|
986
|
+
//# sourceMappingURL=chunk-EEPLAE3H.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_LOCALE,
|
|
3
3
|
TOKENS
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-GRBQ5FRO.js";
|
|
5
5
|
import {
|
|
6
6
|
FormatSyntaxError,
|
|
7
7
|
InvalidLocaleError,
|
|
@@ -199,4 +199,4 @@ export {
|
|
|
199
199
|
applyNumbering,
|
|
200
200
|
applyParseNumbering
|
|
201
201
|
};
|
|
202
|
-
//# sourceMappingURL=chunk-
|
|
202
|
+
//# sourceMappingURL=chunk-EXIJZ4JG.js.map
|
|
@@ -2,6 +2,10 @@ import {
|
|
|
2
2
|
getTemporal,
|
|
3
3
|
subscribeToTemporalChanges
|
|
4
4
|
} from "./chunk-DFWTCRS3.js";
|
|
5
|
+
import {
|
|
6
|
+
dayOfYear,
|
|
7
|
+
isoWeekYearAndWeek
|
|
8
|
+
} from "./chunk-BLZDBPSV.js";
|
|
5
9
|
import {
|
|
6
10
|
FormatSyntaxError,
|
|
7
11
|
InvalidLocaleError,
|
|
@@ -10,10 +14,6 @@ import {
|
|
|
10
14
|
normalizeLocaleTag,
|
|
11
15
|
partValue
|
|
12
16
|
} from "./chunk-QRLQ7RR7.js";
|
|
13
|
-
import {
|
|
14
|
-
dayOfYear,
|
|
15
|
-
isoWeekYearAndWeek
|
|
16
|
-
} from "./chunk-BLZDBPSV.js";
|
|
17
17
|
|
|
18
18
|
// src/tokens.ts
|
|
19
19
|
function requireFields(t, token, ...fields) {
|
|
@@ -364,4 +364,4 @@ export {
|
|
|
364
364
|
DEFAULT_LOCALE,
|
|
365
365
|
TOKENS
|
|
366
366
|
};
|
|
367
|
-
//# sourceMappingURL=chunk-
|
|
367
|
+
//# sourceMappingURL=chunk-GRBQ5FRO.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
differenceInDays
|
|
3
|
+
} from "./chunk-SC6ENLEB.js";
|
|
1
4
|
import {
|
|
2
5
|
DEFAULT_LOCALE
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GRBQ5FRO.js";
|
|
4
7
|
import {
|
|
5
8
|
InvalidLocaleError,
|
|
6
9
|
normalizeLocaleTag
|
|
7
10
|
} from "./chunk-QRLQ7RR7.js";
|
|
8
|
-
import {
|
|
9
|
-
differenceInDays
|
|
10
|
-
} from "./chunk-SC6ENLEB.js";
|
|
11
11
|
|
|
12
12
|
// src/relativeTime.ts
|
|
13
13
|
var rtfCache = /* @__PURE__ */ new Map();
|
|
@@ -62,4 +62,4 @@ export {
|
|
|
62
62
|
formatRelative,
|
|
63
63
|
formatRelativeToNow
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-TDQYKYVJ.js.map
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asDateFieldView
|
|
3
|
+
} from "./chunk-KEPIXQK7.js";
|
|
1
4
|
import {
|
|
2
5
|
MAX_FORMAT_LENGTH
|
|
3
6
|
} from "./chunk-SOPTTXUI.js";
|
|
7
|
+
import {
|
|
8
|
+
daysFromCivil
|
|
9
|
+
} from "./chunk-BLZDBPSV.js";
|
|
4
10
|
import {
|
|
5
11
|
FormatSyntaxError,
|
|
6
12
|
InvalidDurationError,
|
|
@@ -8,12 +14,6 @@ import {
|
|
|
8
14
|
canonicalCacheKey,
|
|
9
15
|
normalizeLocaleTag
|
|
10
16
|
} from "./chunk-QRLQ7RR7.js";
|
|
11
|
-
import {
|
|
12
|
-
asDateFieldView
|
|
13
|
-
} from "./chunk-KEPIXQK7.js";
|
|
14
|
-
import {
|
|
15
|
-
daysFromCivil
|
|
16
|
-
} from "./chunk-BLZDBPSV.js";
|
|
17
17
|
|
|
18
18
|
// src/rounding.ts
|
|
19
19
|
var MS_PER_UNIT = {
|
|
@@ -578,4 +578,4 @@ export {
|
|
|
578
578
|
addDuration,
|
|
579
579
|
subtractDuration
|
|
580
580
|
};
|
|
581
|
-
//# sourceMappingURL=chunk-
|
|
581
|
+
//# sourceMappingURL=chunk-UYKKGBZ3.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTemporal
|
|
3
|
-
} from "./chunk-DFWTCRS3.js";
|
|
4
1
|
import {
|
|
5
2
|
add
|
|
6
3
|
} from "./chunk-SC6ENLEB.js";
|
|
4
|
+
import {
|
|
5
|
+
getTemporal
|
|
6
|
+
} from "./chunk-DFWTCRS3.js";
|
|
7
7
|
|
|
8
8
|
// src/timezone.ts
|
|
9
9
|
function resolveZoned(fields, timeZone, options = {}) {
|
|
@@ -232,4 +232,4 @@ export {
|
|
|
232
232
|
getTransitions,
|
|
233
233
|
possibleInstantsFor
|
|
234
234
|
};
|
|
235
|
-
//# sourceMappingURL=chunk-
|
|
235
|
+
//# sourceMappingURL=chunk-YQGUTK4E.js.map
|
package/dist/duration.js
CHANGED
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
roundDuration,
|
|
10
10
|
subtractDuration,
|
|
11
11
|
totalDuration
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-SOPTTXUI.js";
|
|
14
|
-
import "./chunk-QRLQ7RR7.js";
|
|
12
|
+
} from "./chunk-UYKKGBZ3.js";
|
|
15
13
|
import "./chunk-KEPIXQK7.js";
|
|
14
|
+
import "./chunk-SOPTTXUI.js";
|
|
16
15
|
import "./chunk-BLZDBPSV.js";
|
|
16
|
+
import "./chunk-QRLQ7RR7.js";
|
|
17
17
|
export {
|
|
18
18
|
addDuration,
|
|
19
19
|
balanceDuration,
|
package/dist/format.js
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
compileFormat,
|
|
5
5
|
format,
|
|
6
6
|
formatToParts
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-ACGCGXP5.js";
|
|
8
|
+
import "./chunk-EXIJZ4JG.js";
|
|
9
|
+
import "./chunk-GRBQ5FRO.js";
|
|
10
10
|
import "./chunk-DFWTCRS3.js";
|
|
11
11
|
import "./chunk-SOPTTXUI.js";
|
|
12
|
-
import "./chunk-QRLQ7RR7.js";
|
|
13
12
|
import "./chunk-BLZDBPSV.js";
|
|
13
|
+
import "./chunk-QRLQ7RR7.js";
|
|
14
14
|
export {
|
|
15
15
|
_getPieces,
|
|
16
16
|
_handlerFor,
|
package/dist/index.cjs
CHANGED
|
@@ -167,8 +167,18 @@ __export(index_exports, {
|
|
|
167
167
|
isWeekend: () => isWeekend,
|
|
168
168
|
isYesterday: () => isYesterday,
|
|
169
169
|
isZonedDateTime: () => isZonedDateTime,
|
|
170
|
+
legacyCompileFormat: () => compileFormat2,
|
|
171
|
+
legacyCompileParser: () => compileParser2,
|
|
172
|
+
legacyFormat: () => format2,
|
|
173
|
+
legacyFormatToParts: () => formatToParts2,
|
|
174
|
+
legacyMatchesFormat: () => matchesFormat,
|
|
175
|
+
legacyParse: () => parse2,
|
|
176
|
+
legacyParseToParts: () => parseToParts2,
|
|
177
|
+
legacySafeParse: () => safeParse2,
|
|
178
|
+
legacyTryParse: () => tryParse2,
|
|
170
179
|
listRegisteredGrammars: () => listRegisteredGrammars,
|
|
171
180
|
listTokens: () => listTokens,
|
|
181
|
+
matchesFormat: () => matchesFormat,
|
|
172
182
|
max: () => max,
|
|
173
183
|
mergeIntervals: () => mergeIntervals,
|
|
174
184
|
mergeWithConfig: () => mergeWithConfig,
|
|
@@ -1075,13 +1085,13 @@ var TOKENS = [
|
|
|
1075
1085
|
|
|
1076
1086
|
// src/tokenize.ts
|
|
1077
1087
|
var SORTED_TOKEN_STRINGS = TOKENS.map(([tok]) => tok).sort((a, b) => b.length - a.length);
|
|
1078
|
-
function tokenizeWithSpans(
|
|
1088
|
+
function tokenizeWithSpans(format3) {
|
|
1079
1089
|
const pieces = [];
|
|
1080
1090
|
let i = 0;
|
|
1081
|
-
while (i <
|
|
1082
|
-
const ch =
|
|
1091
|
+
while (i < format3.length) {
|
|
1092
|
+
const ch = format3[i];
|
|
1083
1093
|
if (ch === "'") {
|
|
1084
|
-
if (
|
|
1094
|
+
if (format3[i + 1] === "'") {
|
|
1085
1095
|
appendLiteral(pieces, "'", i, i + 2);
|
|
1086
1096
|
i += 2;
|
|
1087
1097
|
continue;
|
|
@@ -1089,9 +1099,9 @@ function tokenizeWithSpans(format2) {
|
|
|
1089
1099
|
let j = i + 1;
|
|
1090
1100
|
let literal = "";
|
|
1091
1101
|
let closed = false;
|
|
1092
|
-
while (j <
|
|
1093
|
-
if (
|
|
1094
|
-
if (
|
|
1102
|
+
while (j < format3.length) {
|
|
1103
|
+
if (format3[j] === "'") {
|
|
1104
|
+
if (format3[j + 1] === "'") {
|
|
1095
1105
|
literal += "'";
|
|
1096
1106
|
j += 2;
|
|
1097
1107
|
continue;
|
|
@@ -1100,29 +1110,29 @@ function tokenizeWithSpans(format2) {
|
|
|
1100
1110
|
j += 1;
|
|
1101
1111
|
break;
|
|
1102
1112
|
}
|
|
1103
|
-
literal +=
|
|
1113
|
+
literal += format3[j];
|
|
1104
1114
|
j += 1;
|
|
1105
1115
|
}
|
|
1106
1116
|
if (!closed) {
|
|
1107
1117
|
throw new FormatSyntaxError({
|
|
1108
|
-
format:
|
|
1109
|
-
message: `temporal-fmt: unterminated quote in format string "${
|
|
1118
|
+
format: format3,
|
|
1119
|
+
message: `temporal-fmt: unterminated quote in format string "${format3}"`
|
|
1110
1120
|
});
|
|
1111
1121
|
}
|
|
1112
1122
|
appendLiteral(pieces, literal, i, j);
|
|
1113
1123
|
i = j;
|
|
1114
1124
|
continue;
|
|
1115
1125
|
}
|
|
1116
|
-
const match = SORTED_TOKEN_STRINGS.find((tok) =>
|
|
1126
|
+
const match = SORTED_TOKEN_STRINGS.find((tok) => format3.startsWith(tok, i));
|
|
1117
1127
|
if (match) {
|
|
1118
1128
|
const runChar = match[match.length - 1];
|
|
1119
|
-
if (
|
|
1129
|
+
if (format3[i + match.length] === runChar) {
|
|
1120
1130
|
let end = i + match.length;
|
|
1121
|
-
while (
|
|
1131
|
+
while (format3[end] === runChar) end += 1;
|
|
1122
1132
|
throw new UnknownTokenError({
|
|
1123
|
-
format:
|
|
1124
|
-
token:
|
|
1125
|
-
message: `temporal-fmt: "${
|
|
1133
|
+
format: format3,
|
|
1134
|
+
token: format3.slice(i, end),
|
|
1135
|
+
message: `temporal-fmt: "${format3.slice(i, end)}" in format string "${format3}" isn't a recognized token \u2014 did you mean "${match}"?`
|
|
1126
1136
|
});
|
|
1127
1137
|
}
|
|
1128
1138
|
pieces.push({ kind: "token", value: match, start: i, end: i + match.length });
|
|
@@ -1134,8 +1144,8 @@ function tokenizeWithSpans(format2) {
|
|
|
1134
1144
|
}
|
|
1135
1145
|
return pieces;
|
|
1136
1146
|
}
|
|
1137
|
-
function tokenize(
|
|
1138
|
-
return tokenizeWithSpans(
|
|
1147
|
+
function tokenize(format3) {
|
|
1148
|
+
return tokenizeWithSpans(format3).map(({ kind, value }) => ({ kind, value }));
|
|
1139
1149
|
}
|
|
1140
1150
|
function appendLiteral(pieces, value, start, end) {
|
|
1141
1151
|
const last = pieces[pieces.length - 1];
|
|
@@ -2366,6 +2376,96 @@ function compileParser(formatStr, options = {}) {
|
|
|
2366
2376
|
};
|
|
2367
2377
|
}
|
|
2368
2378
|
|
|
2379
|
+
// src/legacy/matchesFormat.ts
|
|
2380
|
+
var patternCache2 = /* @__PURE__ */ new Map();
|
|
2381
|
+
var MAX_CACHE_SIZE3 = 500;
|
|
2382
|
+
function getPattern2(formatStr, locale) {
|
|
2383
|
+
const key = locale + "\0" + formatStr;
|
|
2384
|
+
const cached = patternCache2.get(key);
|
|
2385
|
+
if (cached) return cached;
|
|
2386
|
+
if (patternCache2.size >= MAX_CACHE_SIZE3) {
|
|
2387
|
+
const oldestKey = patternCache2.keys().next().value;
|
|
2388
|
+
if (oldestKey !== void 0) patternCache2.delete(oldestKey);
|
|
2389
|
+
}
|
|
2390
|
+
const pattern = buildCapturingPattern(tokenize(formatStr), locale);
|
|
2391
|
+
patternCache2.set(key, pattern);
|
|
2392
|
+
return pattern;
|
|
2393
|
+
}
|
|
2394
|
+
function matchesFormat(formatStr, input, options = {}) {
|
|
2395
|
+
try {
|
|
2396
|
+
if (formatStr.length > MAX_FORMAT_LENGTH) {
|
|
2397
|
+
throw new Error(
|
|
2398
|
+
`temporal-fmt: format string exceeds maximum length of ${MAX_FORMAT_LENGTH} characters (got ${formatStr.length}).`
|
|
2399
|
+
);
|
|
2400
|
+
}
|
|
2401
|
+
const locale = options.locale ?? DEFAULT_LOCALE;
|
|
2402
|
+
const pattern = getPattern2(formatStr, locale);
|
|
2403
|
+
const match = pattern.regex.exec(input);
|
|
2404
|
+
if (!match) return false;
|
|
2405
|
+
for (const run of pattern.ambiguousRuns) {
|
|
2406
|
+
const range = match.indices?.groups?.[run.groupName];
|
|
2407
|
+
if (!range || enumerateValidSplits(input.slice(range[0], range[1]), run.tokens).length === 0) {
|
|
2408
|
+
return false;
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
return true;
|
|
2412
|
+
} catch (error) {
|
|
2413
|
+
if (error instanceof TemporalFmtError) throw new Error(error.message);
|
|
2414
|
+
throw error;
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
|
|
2418
|
+
// src/legacy/index.ts
|
|
2419
|
+
function withLegacyErrors(operation) {
|
|
2420
|
+
try {
|
|
2421
|
+
return operation();
|
|
2422
|
+
} catch (error) {
|
|
2423
|
+
if (error instanceof TemporalFmtError) {
|
|
2424
|
+
throw new Error(error.message);
|
|
2425
|
+
}
|
|
2426
|
+
throw error;
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
function toLegacySafeParseResult(result) {
|
|
2430
|
+
return result.ok ? result : { ok: false, error: new Error(result.error.message) };
|
|
2431
|
+
}
|
|
2432
|
+
function format2(temporal, formatStr, options = {}) {
|
|
2433
|
+
return withLegacyErrors(() => format(temporal, formatStr, options));
|
|
2434
|
+
}
|
|
2435
|
+
function formatToParts2(temporal, formatStr, options = {}) {
|
|
2436
|
+
return withLegacyErrors(() => formatToParts(temporal, formatStr, options));
|
|
2437
|
+
}
|
|
2438
|
+
function compileFormat2(formatStr) {
|
|
2439
|
+
const compiled = withLegacyErrors(() => compileFormat(formatStr));
|
|
2440
|
+
return {
|
|
2441
|
+
...compiled,
|
|
2442
|
+
format: (temporal, options) => withLegacyErrors(() => compiled.format(temporal, options)),
|
|
2443
|
+
formatToParts: (temporal, options) => withLegacyErrors(() => compiled.formatToParts(temporal, options))
|
|
2444
|
+
};
|
|
2445
|
+
}
|
|
2446
|
+
function parse2(formatStr, input, options = {}) {
|
|
2447
|
+
return withLegacyErrors(() => parse(formatStr, input, options));
|
|
2448
|
+
}
|
|
2449
|
+
function safeParse2(formatStr, input, options = {}) {
|
|
2450
|
+
return toLegacySafeParseResult(safeParse(formatStr, input, options));
|
|
2451
|
+
}
|
|
2452
|
+
function tryParse2(formatStr, input, options = {}) {
|
|
2453
|
+
return tryParse(formatStr, input, options);
|
|
2454
|
+
}
|
|
2455
|
+
function parseToParts2(formatStr, input, options = {}) {
|
|
2456
|
+
return withLegacyErrors(() => parseToParts(formatStr, input, options));
|
|
2457
|
+
}
|
|
2458
|
+
function compileParser2(formatStr, options = {}) {
|
|
2459
|
+
const compiled = withLegacyErrors(() => compileParser(formatStr, options));
|
|
2460
|
+
return {
|
|
2461
|
+
...compiled,
|
|
2462
|
+
parse: (input, callOptions) => withLegacyErrors(() => compiled.parse(input, callOptions)),
|
|
2463
|
+
safeParse: (input, callOptions) => toLegacySafeParseResult(compiled.safeParse(input, callOptions)),
|
|
2464
|
+
tryParse: (input, callOptions) => compiled.tryParse(input, callOptions),
|
|
2465
|
+
parseToParts: (input, callOptions) => withLegacyErrors(() => compiled.parseToParts(input, callOptions))
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2369
2469
|
// src/formatDuration.ts
|
|
2370
2470
|
var DURATION_UNITS = {
|
|
2371
2471
|
y: { longSingular: "year", longPlural: "years", shortSingular: "yr", shortPlural: "yrs", field: "years", intlUnit: "year" },
|
|
@@ -2378,13 +2478,13 @@ var DURATION_UNITS = {
|
|
|
2378
2478
|
S: { longSingular: "millisecond", longPlural: "milliseconds", shortSingular: "ms", shortPlural: "ms", field: "milliseconds", intlUnit: "millisecond" }
|
|
2379
2479
|
};
|
|
2380
2480
|
var DURATION_TOKEN_STRINGS = Object.keys(DURATION_UNITS).flatMap((single) => [single + single + single, single + single, single]).sort((a, b) => b.length - a.length);
|
|
2381
|
-
function tokenizeDuration(
|
|
2481
|
+
function tokenizeDuration(format3) {
|
|
2382
2482
|
const pieces = [];
|
|
2383
2483
|
let i = 0;
|
|
2384
|
-
while (i <
|
|
2385
|
-
const ch =
|
|
2484
|
+
while (i < format3.length) {
|
|
2485
|
+
const ch = format3[i];
|
|
2386
2486
|
if (ch === "'") {
|
|
2387
|
-
if (
|
|
2487
|
+
if (format3[i + 1] === "'") {
|
|
2388
2488
|
appendLiteral2(pieces, "'");
|
|
2389
2489
|
i += 2;
|
|
2390
2490
|
continue;
|
|
@@ -2392,9 +2492,9 @@ function tokenizeDuration(format2) {
|
|
|
2392
2492
|
let j = i + 1;
|
|
2393
2493
|
let literal = "";
|
|
2394
2494
|
let closed = false;
|
|
2395
|
-
while (j <
|
|
2396
|
-
if (
|
|
2397
|
-
if (
|
|
2495
|
+
while (j < format3.length) {
|
|
2496
|
+
if (format3[j] === "'") {
|
|
2497
|
+
if (format3[j + 1] === "'") {
|
|
2398
2498
|
literal += "'";
|
|
2399
2499
|
j += 2;
|
|
2400
2500
|
continue;
|
|
@@ -2403,17 +2503,17 @@ function tokenizeDuration(format2) {
|
|
|
2403
2503
|
j += 1;
|
|
2404
2504
|
break;
|
|
2405
2505
|
}
|
|
2406
|
-
literal +=
|
|
2506
|
+
literal += format3[j];
|
|
2407
2507
|
j += 1;
|
|
2408
2508
|
}
|
|
2409
2509
|
if (!closed) {
|
|
2410
|
-
throw new Error(`temporal-fmt: unterminated quote in duration format string "${
|
|
2510
|
+
throw new Error(`temporal-fmt: unterminated quote in duration format string "${format3}"`);
|
|
2411
2511
|
}
|
|
2412
2512
|
appendLiteral2(pieces, literal);
|
|
2413
2513
|
i = j;
|
|
2414
2514
|
continue;
|
|
2415
2515
|
}
|
|
2416
|
-
const match = DURATION_TOKEN_STRINGS.find((tok) =>
|
|
2516
|
+
const match = DURATION_TOKEN_STRINGS.find((tok) => format3.startsWith(tok, i));
|
|
2417
2517
|
if (match) {
|
|
2418
2518
|
const unit = match[0];
|
|
2419
2519
|
const form = match.length === 1 ? "numeric" : match.length === 2 ? "short" : "long";
|
|
@@ -7222,8 +7322,18 @@ function translateDateFnsFormatString(formatStr) {
|
|
|
7222
7322
|
isWeekend,
|
|
7223
7323
|
isYesterday,
|
|
7224
7324
|
isZonedDateTime,
|
|
7325
|
+
legacyCompileFormat,
|
|
7326
|
+
legacyCompileParser,
|
|
7327
|
+
legacyFormat,
|
|
7328
|
+
legacyFormatToParts,
|
|
7329
|
+
legacyMatchesFormat,
|
|
7330
|
+
legacyParse,
|
|
7331
|
+
legacyParseToParts,
|
|
7332
|
+
legacySafeParse,
|
|
7333
|
+
legacyTryParse,
|
|
7225
7334
|
listRegisteredGrammars,
|
|
7226
7335
|
listTokens,
|
|
7336
|
+
matchesFormat,
|
|
7227
7337
|
max,
|
|
7228
7338
|
mergeIntervals,
|
|
7229
7339
|
mergeWithConfig,
|