@optique/temporal 1.0.0-dev.783 → 1.0.0-dev.885
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/index.cjs +30 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +30 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,9 @@ const __optique_core_message = __toESM(require("@optique/core/message"));
|
|
|
26
26
|
const __optique_core_nonempty = __toESM(require("@optique/core/nonempty"));
|
|
27
27
|
|
|
28
28
|
//#region src/index.ts
|
|
29
|
+
function ensureTemporal() {
|
|
30
|
+
if (typeof globalThis.Temporal === "undefined") throw new TypeError("Temporal API is not available. Use a runtime with Temporal support or install a polyfill like @js-temporal/polyfill.");
|
|
31
|
+
}
|
|
29
32
|
/**
|
|
30
33
|
* Creates a ValueParser for parsing Temporal.Instant from ISO 8601 strings.
|
|
31
34
|
*
|
|
@@ -36,6 +39,8 @@ const __optique_core_nonempty = __toESM(require("@optique/core/nonempty"));
|
|
|
36
39
|
*
|
|
37
40
|
* @param options Configuration options for the instant parser.
|
|
38
41
|
* @returns A ValueParser that parses strings into Temporal.Instant values.
|
|
42
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
43
|
+
* at runtime.
|
|
39
44
|
*/
|
|
40
45
|
function instant(options = {}) {
|
|
41
46
|
const metavar = options.metavar ?? "TIMESTAMP";
|
|
@@ -44,6 +49,7 @@ function instant(options = {}) {
|
|
|
44
49
|
$mode: "sync",
|
|
45
50
|
metavar,
|
|
46
51
|
parse(input) {
|
|
52
|
+
ensureTemporal();
|
|
47
53
|
try {
|
|
48
54
|
const value = Temporal.Instant.from(input);
|
|
49
55
|
return {
|
|
@@ -73,6 +79,8 @@ function instant(options = {}) {
|
|
|
73
79
|
*
|
|
74
80
|
* @param options Configuration options for the duration parser.
|
|
75
81
|
* @returns A ValueParser that parses strings into Temporal.Duration values.
|
|
82
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
83
|
+
* at runtime.
|
|
76
84
|
*/
|
|
77
85
|
function duration(options = {}) {
|
|
78
86
|
const metavar = options.metavar ?? "DURATION";
|
|
@@ -81,6 +89,7 @@ function duration(options = {}) {
|
|
|
81
89
|
$mode: "sync",
|
|
82
90
|
metavar,
|
|
83
91
|
parse(input) {
|
|
92
|
+
ensureTemporal();
|
|
84
93
|
try {
|
|
85
94
|
const value = Temporal.Duration.from(input);
|
|
86
95
|
return {
|
|
@@ -109,6 +118,8 @@ function duration(options = {}) {
|
|
|
109
118
|
*
|
|
110
119
|
* @param options Configuration options for the zoned datetime parser.
|
|
111
120
|
* @returns A ValueParser that parses strings into Temporal.ZonedDateTime values.
|
|
121
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
122
|
+
* at runtime.
|
|
112
123
|
*/
|
|
113
124
|
function zonedDateTime(options = {}) {
|
|
114
125
|
const metavar = options.metavar ?? "ZONED_DATETIME";
|
|
@@ -117,6 +128,7 @@ function zonedDateTime(options = {}) {
|
|
|
117
128
|
$mode: "sync",
|
|
118
129
|
metavar,
|
|
119
130
|
parse(input) {
|
|
131
|
+
ensureTemporal();
|
|
120
132
|
try {
|
|
121
133
|
const value = Temporal.ZonedDateTime.from(input);
|
|
122
134
|
return {
|
|
@@ -145,6 +157,8 @@ function zonedDateTime(options = {}) {
|
|
|
145
157
|
*
|
|
146
158
|
* @param options Configuration options for the plain date parser.
|
|
147
159
|
* @returns A ValueParser that parses strings into Temporal.PlainDate values.
|
|
160
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
161
|
+
* at runtime.
|
|
148
162
|
*/
|
|
149
163
|
function plainDate(options = {}) {
|
|
150
164
|
const metavar = options.metavar ?? "DATE";
|
|
@@ -153,6 +167,7 @@ function plainDate(options = {}) {
|
|
|
153
167
|
$mode: "sync",
|
|
154
168
|
metavar,
|
|
155
169
|
parse(input) {
|
|
170
|
+
ensureTemporal();
|
|
156
171
|
try {
|
|
157
172
|
const value = Temporal.PlainDate.from(input);
|
|
158
173
|
return {
|
|
@@ -181,6 +196,8 @@ function plainDate(options = {}) {
|
|
|
181
196
|
*
|
|
182
197
|
* @param options Configuration options for the plain time parser.
|
|
183
198
|
* @returns A ValueParser that parses strings into Temporal.PlainTime values.
|
|
199
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
200
|
+
* at runtime.
|
|
184
201
|
*/
|
|
185
202
|
function plainTime(options = {}) {
|
|
186
203
|
const metavar = options.metavar ?? "TIME";
|
|
@@ -189,6 +206,7 @@ function plainTime(options = {}) {
|
|
|
189
206
|
$mode: "sync",
|
|
190
207
|
metavar,
|
|
191
208
|
parse(input) {
|
|
209
|
+
ensureTemporal();
|
|
192
210
|
try {
|
|
193
211
|
const value = Temporal.PlainTime.from(input);
|
|
194
212
|
return {
|
|
@@ -217,6 +235,8 @@ function plainTime(options = {}) {
|
|
|
217
235
|
*
|
|
218
236
|
* @param options Configuration options for the plain datetime parser.
|
|
219
237
|
* @returns A ValueParser that parses strings into Temporal.PlainDateTime values.
|
|
238
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
239
|
+
* at runtime.
|
|
220
240
|
*/
|
|
221
241
|
function plainDateTime(options = {}) {
|
|
222
242
|
const metavar = options.metavar ?? "DATETIME";
|
|
@@ -225,6 +245,7 @@ function plainDateTime(options = {}) {
|
|
|
225
245
|
$mode: "sync",
|
|
226
246
|
metavar,
|
|
227
247
|
parse(input) {
|
|
248
|
+
ensureTemporal();
|
|
228
249
|
try {
|
|
229
250
|
const value = Temporal.PlainDateTime.from(input);
|
|
230
251
|
return {
|
|
@@ -253,6 +274,8 @@ function plainDateTime(options = {}) {
|
|
|
253
274
|
*
|
|
254
275
|
* @param options Configuration options for the plain year-month parser.
|
|
255
276
|
* @returns A ValueParser that parses strings into Temporal.PlainYearMonth values.
|
|
277
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
278
|
+
* at runtime.
|
|
256
279
|
*/
|
|
257
280
|
function plainYearMonth(options = {}) {
|
|
258
281
|
const metavar = options.metavar ?? "YEAR-MONTH";
|
|
@@ -261,6 +284,7 @@ function plainYearMonth(options = {}) {
|
|
|
261
284
|
$mode: "sync",
|
|
262
285
|
metavar,
|
|
263
286
|
parse(input) {
|
|
287
|
+
ensureTemporal();
|
|
264
288
|
try {
|
|
265
289
|
const value = Temporal.PlainYearMonth.from(input);
|
|
266
290
|
return {
|
|
@@ -289,6 +313,8 @@ function plainYearMonth(options = {}) {
|
|
|
289
313
|
*
|
|
290
314
|
* @param options Configuration options for the plain month-day parser.
|
|
291
315
|
* @returns A ValueParser that parses strings into Temporal.PlainMonthDay values.
|
|
316
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
317
|
+
* at runtime.
|
|
292
318
|
*/
|
|
293
319
|
function plainMonthDay(options = {}) {
|
|
294
320
|
const metavar = options.metavar ?? "--MONTH-DAY";
|
|
@@ -297,6 +323,7 @@ function plainMonthDay(options = {}) {
|
|
|
297
323
|
$mode: "sync",
|
|
298
324
|
metavar,
|
|
299
325
|
parse(input) {
|
|
326
|
+
ensureTemporal();
|
|
300
327
|
try {
|
|
301
328
|
const value = Temporal.PlainMonthDay.from(input);
|
|
302
329
|
return {
|
|
@@ -327,6 +354,8 @@ function plainMonthDay(options = {}) {
|
|
|
327
354
|
*
|
|
328
355
|
* @param options Configuration options for the timezone parser.
|
|
329
356
|
* @returns A ValueParser that parses and validates timezone identifiers.
|
|
357
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
358
|
+
* at runtime.
|
|
330
359
|
*/
|
|
331
360
|
function timeZone(options = {}) {
|
|
332
361
|
const metavar = options.metavar ?? "TIMEZONE";
|
|
@@ -335,6 +364,7 @@ function timeZone(options = {}) {
|
|
|
335
364
|
$mode: "sync",
|
|
336
365
|
metavar,
|
|
337
366
|
parse(input) {
|
|
367
|
+
ensureTemporal();
|
|
338
368
|
try {
|
|
339
369
|
Temporal.ZonedDateTime.from({
|
|
340
370
|
year: 2020,
|
package/dist/index.d.cts
CHANGED
|
@@ -248,6 +248,8 @@ interface TimeZoneOptions {
|
|
|
248
248
|
*
|
|
249
249
|
* @param options Configuration options for the instant parser.
|
|
250
250
|
* @returns A ValueParser that parses strings into Temporal.Instant values.
|
|
251
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
252
|
+
* at runtime.
|
|
251
253
|
*/
|
|
252
254
|
declare function instant(options?: InstantOptions): ValueParser<"sync", Temporal.Instant>;
|
|
253
255
|
/**
|
|
@@ -261,6 +263,8 @@ declare function instant(options?: InstantOptions): ValueParser<"sync", Temporal
|
|
|
261
263
|
*
|
|
262
264
|
* @param options Configuration options for the duration parser.
|
|
263
265
|
* @returns A ValueParser that parses strings into Temporal.Duration values.
|
|
266
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
267
|
+
* at runtime.
|
|
264
268
|
*/
|
|
265
269
|
declare function duration(options?: DurationOptions): ValueParser<"sync", Temporal.Duration>;
|
|
266
270
|
/**
|
|
@@ -273,6 +277,8 @@ declare function duration(options?: DurationOptions): ValueParser<"sync", Tempor
|
|
|
273
277
|
*
|
|
274
278
|
* @param options Configuration options for the zoned datetime parser.
|
|
275
279
|
* @returns A ValueParser that parses strings into Temporal.ZonedDateTime values.
|
|
280
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
281
|
+
* at runtime.
|
|
276
282
|
*/
|
|
277
283
|
declare function zonedDateTime(options?: ZonedDateTimeOptions): ValueParser<"sync", Temporal.ZonedDateTime>;
|
|
278
284
|
/**
|
|
@@ -285,6 +291,8 @@ declare function zonedDateTime(options?: ZonedDateTimeOptions): ValueParser<"syn
|
|
|
285
291
|
*
|
|
286
292
|
* @param options Configuration options for the plain date parser.
|
|
287
293
|
* @returns A ValueParser that parses strings into Temporal.PlainDate values.
|
|
294
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
295
|
+
* at runtime.
|
|
288
296
|
*/
|
|
289
297
|
declare function plainDate(options?: PlainDateOptions): ValueParser<"sync", Temporal.PlainDate>;
|
|
290
298
|
/**
|
|
@@ -297,6 +305,8 @@ declare function plainDate(options?: PlainDateOptions): ValueParser<"sync", Temp
|
|
|
297
305
|
*
|
|
298
306
|
* @param options Configuration options for the plain time parser.
|
|
299
307
|
* @returns A ValueParser that parses strings into Temporal.PlainTime values.
|
|
308
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
309
|
+
* at runtime.
|
|
300
310
|
*/
|
|
301
311
|
declare function plainTime(options?: PlainTimeOptions): ValueParser<"sync", Temporal.PlainTime>;
|
|
302
312
|
/**
|
|
@@ -309,6 +319,8 @@ declare function plainTime(options?: PlainTimeOptions): ValueParser<"sync", Temp
|
|
|
309
319
|
*
|
|
310
320
|
* @param options Configuration options for the plain datetime parser.
|
|
311
321
|
* @returns A ValueParser that parses strings into Temporal.PlainDateTime values.
|
|
322
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
323
|
+
* at runtime.
|
|
312
324
|
*/
|
|
313
325
|
declare function plainDateTime(options?: PlainDateTimeOptions): ValueParser<"sync", Temporal.PlainDateTime>;
|
|
314
326
|
/**
|
|
@@ -321,6 +333,8 @@ declare function plainDateTime(options?: PlainDateTimeOptions): ValueParser<"syn
|
|
|
321
333
|
*
|
|
322
334
|
* @param options Configuration options for the plain year-month parser.
|
|
323
335
|
* @returns A ValueParser that parses strings into Temporal.PlainYearMonth values.
|
|
336
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
337
|
+
* at runtime.
|
|
324
338
|
*/
|
|
325
339
|
declare function plainYearMonth(options?: PlainYearMonthOptions): ValueParser<"sync", Temporal.PlainYearMonth>;
|
|
326
340
|
/**
|
|
@@ -333,6 +347,8 @@ declare function plainYearMonth(options?: PlainYearMonthOptions): ValueParser<"s
|
|
|
333
347
|
*
|
|
334
348
|
* @param options Configuration options for the plain month-day parser.
|
|
335
349
|
* @returns A ValueParser that parses strings into Temporal.PlainMonthDay values.
|
|
350
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
351
|
+
* at runtime.
|
|
336
352
|
*/
|
|
337
353
|
declare function plainMonthDay(options?: PlainMonthDayOptions): ValueParser<"sync", Temporal.PlainMonthDay>;
|
|
338
354
|
/**
|
|
@@ -347,6 +363,8 @@ declare function plainMonthDay(options?: PlainMonthDayOptions): ValueParser<"syn
|
|
|
347
363
|
*
|
|
348
364
|
* @param options Configuration options for the timezone parser.
|
|
349
365
|
* @returns A ValueParser that parses and validates timezone identifiers.
|
|
366
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
367
|
+
* at runtime.
|
|
350
368
|
*/
|
|
351
369
|
declare function timeZone(options?: TimeZoneOptions): ValueParser<"sync", TimeZone>;
|
|
352
370
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -249,6 +249,8 @@ interface TimeZoneOptions {
|
|
|
249
249
|
*
|
|
250
250
|
* @param options Configuration options for the instant parser.
|
|
251
251
|
* @returns A ValueParser that parses strings into Temporal.Instant values.
|
|
252
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
253
|
+
* at runtime.
|
|
252
254
|
*/
|
|
253
255
|
declare function instant(options?: InstantOptions): ValueParser<"sync", Temporal.Instant>;
|
|
254
256
|
/**
|
|
@@ -262,6 +264,8 @@ declare function instant(options?: InstantOptions): ValueParser<"sync", Temporal
|
|
|
262
264
|
*
|
|
263
265
|
* @param options Configuration options for the duration parser.
|
|
264
266
|
* @returns A ValueParser that parses strings into Temporal.Duration values.
|
|
267
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
268
|
+
* at runtime.
|
|
265
269
|
*/
|
|
266
270
|
declare function duration(options?: DurationOptions): ValueParser<"sync", Temporal.Duration>;
|
|
267
271
|
/**
|
|
@@ -274,6 +278,8 @@ declare function duration(options?: DurationOptions): ValueParser<"sync", Tempor
|
|
|
274
278
|
*
|
|
275
279
|
* @param options Configuration options for the zoned datetime parser.
|
|
276
280
|
* @returns A ValueParser that parses strings into Temporal.ZonedDateTime values.
|
|
281
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
282
|
+
* at runtime.
|
|
277
283
|
*/
|
|
278
284
|
declare function zonedDateTime(options?: ZonedDateTimeOptions): ValueParser<"sync", Temporal.ZonedDateTime>;
|
|
279
285
|
/**
|
|
@@ -286,6 +292,8 @@ declare function zonedDateTime(options?: ZonedDateTimeOptions): ValueParser<"syn
|
|
|
286
292
|
*
|
|
287
293
|
* @param options Configuration options for the plain date parser.
|
|
288
294
|
* @returns A ValueParser that parses strings into Temporal.PlainDate values.
|
|
295
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
296
|
+
* at runtime.
|
|
289
297
|
*/
|
|
290
298
|
declare function plainDate(options?: PlainDateOptions): ValueParser<"sync", Temporal.PlainDate>;
|
|
291
299
|
/**
|
|
@@ -298,6 +306,8 @@ declare function plainDate(options?: PlainDateOptions): ValueParser<"sync", Temp
|
|
|
298
306
|
*
|
|
299
307
|
* @param options Configuration options for the plain time parser.
|
|
300
308
|
* @returns A ValueParser that parses strings into Temporal.PlainTime values.
|
|
309
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
310
|
+
* at runtime.
|
|
301
311
|
*/
|
|
302
312
|
declare function plainTime(options?: PlainTimeOptions): ValueParser<"sync", Temporal.PlainTime>;
|
|
303
313
|
/**
|
|
@@ -310,6 +320,8 @@ declare function plainTime(options?: PlainTimeOptions): ValueParser<"sync", Temp
|
|
|
310
320
|
*
|
|
311
321
|
* @param options Configuration options for the plain datetime parser.
|
|
312
322
|
* @returns A ValueParser that parses strings into Temporal.PlainDateTime values.
|
|
323
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
324
|
+
* at runtime.
|
|
313
325
|
*/
|
|
314
326
|
declare function plainDateTime(options?: PlainDateTimeOptions): ValueParser<"sync", Temporal.PlainDateTime>;
|
|
315
327
|
/**
|
|
@@ -322,6 +334,8 @@ declare function plainDateTime(options?: PlainDateTimeOptions): ValueParser<"syn
|
|
|
322
334
|
*
|
|
323
335
|
* @param options Configuration options for the plain year-month parser.
|
|
324
336
|
* @returns A ValueParser that parses strings into Temporal.PlainYearMonth values.
|
|
337
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
338
|
+
* at runtime.
|
|
325
339
|
*/
|
|
326
340
|
declare function plainYearMonth(options?: PlainYearMonthOptions): ValueParser<"sync", Temporal.PlainYearMonth>;
|
|
327
341
|
/**
|
|
@@ -334,6 +348,8 @@ declare function plainYearMonth(options?: PlainYearMonthOptions): ValueParser<"s
|
|
|
334
348
|
*
|
|
335
349
|
* @param options Configuration options for the plain month-day parser.
|
|
336
350
|
* @returns A ValueParser that parses strings into Temporal.PlainMonthDay values.
|
|
351
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
352
|
+
* at runtime.
|
|
337
353
|
*/
|
|
338
354
|
declare function plainMonthDay(options?: PlainMonthDayOptions): ValueParser<"sync", Temporal.PlainMonthDay>;
|
|
339
355
|
/**
|
|
@@ -348,6 +364,8 @@ declare function plainMonthDay(options?: PlainMonthDayOptions): ValueParser<"syn
|
|
|
348
364
|
*
|
|
349
365
|
* @param options Configuration options for the timezone parser.
|
|
350
366
|
* @returns A ValueParser that parses and validates timezone identifiers.
|
|
367
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
368
|
+
* at runtime.
|
|
351
369
|
*/
|
|
352
370
|
declare function timeZone(options?: TimeZoneOptions): ValueParser<"sync", TimeZone>;
|
|
353
371
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,9 @@ import { message } from "@optique/core/message";
|
|
|
3
3
|
import { ensureNonEmptyString } from "@optique/core/nonempty";
|
|
4
4
|
|
|
5
5
|
//#region src/index.ts
|
|
6
|
+
function ensureTemporal() {
|
|
7
|
+
if (typeof globalThis.Temporal === "undefined") throw new TypeError("Temporal API is not available. Use a runtime with Temporal support or install a polyfill like @js-temporal/polyfill.");
|
|
8
|
+
}
|
|
6
9
|
/**
|
|
7
10
|
* Creates a ValueParser for parsing Temporal.Instant from ISO 8601 strings.
|
|
8
11
|
*
|
|
@@ -13,6 +16,8 @@ import { ensureNonEmptyString } from "@optique/core/nonempty";
|
|
|
13
16
|
*
|
|
14
17
|
* @param options Configuration options for the instant parser.
|
|
15
18
|
* @returns A ValueParser that parses strings into Temporal.Instant values.
|
|
19
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
20
|
+
* at runtime.
|
|
16
21
|
*/
|
|
17
22
|
function instant(options = {}) {
|
|
18
23
|
const metavar = options.metavar ?? "TIMESTAMP";
|
|
@@ -21,6 +26,7 @@ function instant(options = {}) {
|
|
|
21
26
|
$mode: "sync",
|
|
22
27
|
metavar,
|
|
23
28
|
parse(input) {
|
|
29
|
+
ensureTemporal();
|
|
24
30
|
try {
|
|
25
31
|
const value = Temporal.Instant.from(input);
|
|
26
32
|
return {
|
|
@@ -50,6 +56,8 @@ function instant(options = {}) {
|
|
|
50
56
|
*
|
|
51
57
|
* @param options Configuration options for the duration parser.
|
|
52
58
|
* @returns A ValueParser that parses strings into Temporal.Duration values.
|
|
59
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
60
|
+
* at runtime.
|
|
53
61
|
*/
|
|
54
62
|
function duration(options = {}) {
|
|
55
63
|
const metavar = options.metavar ?? "DURATION";
|
|
@@ -58,6 +66,7 @@ function duration(options = {}) {
|
|
|
58
66
|
$mode: "sync",
|
|
59
67
|
metavar,
|
|
60
68
|
parse(input) {
|
|
69
|
+
ensureTemporal();
|
|
61
70
|
try {
|
|
62
71
|
const value = Temporal.Duration.from(input);
|
|
63
72
|
return {
|
|
@@ -86,6 +95,8 @@ function duration(options = {}) {
|
|
|
86
95
|
*
|
|
87
96
|
* @param options Configuration options for the zoned datetime parser.
|
|
88
97
|
* @returns A ValueParser that parses strings into Temporal.ZonedDateTime values.
|
|
98
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
99
|
+
* at runtime.
|
|
89
100
|
*/
|
|
90
101
|
function zonedDateTime(options = {}) {
|
|
91
102
|
const metavar = options.metavar ?? "ZONED_DATETIME";
|
|
@@ -94,6 +105,7 @@ function zonedDateTime(options = {}) {
|
|
|
94
105
|
$mode: "sync",
|
|
95
106
|
metavar,
|
|
96
107
|
parse(input) {
|
|
108
|
+
ensureTemporal();
|
|
97
109
|
try {
|
|
98
110
|
const value = Temporal.ZonedDateTime.from(input);
|
|
99
111
|
return {
|
|
@@ -122,6 +134,8 @@ function zonedDateTime(options = {}) {
|
|
|
122
134
|
*
|
|
123
135
|
* @param options Configuration options for the plain date parser.
|
|
124
136
|
* @returns A ValueParser that parses strings into Temporal.PlainDate values.
|
|
137
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
138
|
+
* at runtime.
|
|
125
139
|
*/
|
|
126
140
|
function plainDate(options = {}) {
|
|
127
141
|
const metavar = options.metavar ?? "DATE";
|
|
@@ -130,6 +144,7 @@ function plainDate(options = {}) {
|
|
|
130
144
|
$mode: "sync",
|
|
131
145
|
metavar,
|
|
132
146
|
parse(input) {
|
|
147
|
+
ensureTemporal();
|
|
133
148
|
try {
|
|
134
149
|
const value = Temporal.PlainDate.from(input);
|
|
135
150
|
return {
|
|
@@ -158,6 +173,8 @@ function plainDate(options = {}) {
|
|
|
158
173
|
*
|
|
159
174
|
* @param options Configuration options for the plain time parser.
|
|
160
175
|
* @returns A ValueParser that parses strings into Temporal.PlainTime values.
|
|
176
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
177
|
+
* at runtime.
|
|
161
178
|
*/
|
|
162
179
|
function plainTime(options = {}) {
|
|
163
180
|
const metavar = options.metavar ?? "TIME";
|
|
@@ -166,6 +183,7 @@ function plainTime(options = {}) {
|
|
|
166
183
|
$mode: "sync",
|
|
167
184
|
metavar,
|
|
168
185
|
parse(input) {
|
|
186
|
+
ensureTemporal();
|
|
169
187
|
try {
|
|
170
188
|
const value = Temporal.PlainTime.from(input);
|
|
171
189
|
return {
|
|
@@ -194,6 +212,8 @@ function plainTime(options = {}) {
|
|
|
194
212
|
*
|
|
195
213
|
* @param options Configuration options for the plain datetime parser.
|
|
196
214
|
* @returns A ValueParser that parses strings into Temporal.PlainDateTime values.
|
|
215
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
216
|
+
* at runtime.
|
|
197
217
|
*/
|
|
198
218
|
function plainDateTime(options = {}) {
|
|
199
219
|
const metavar = options.metavar ?? "DATETIME";
|
|
@@ -202,6 +222,7 @@ function plainDateTime(options = {}) {
|
|
|
202
222
|
$mode: "sync",
|
|
203
223
|
metavar,
|
|
204
224
|
parse(input) {
|
|
225
|
+
ensureTemporal();
|
|
205
226
|
try {
|
|
206
227
|
const value = Temporal.PlainDateTime.from(input);
|
|
207
228
|
return {
|
|
@@ -230,6 +251,8 @@ function plainDateTime(options = {}) {
|
|
|
230
251
|
*
|
|
231
252
|
* @param options Configuration options for the plain year-month parser.
|
|
232
253
|
* @returns A ValueParser that parses strings into Temporal.PlainYearMonth values.
|
|
254
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
255
|
+
* at runtime.
|
|
233
256
|
*/
|
|
234
257
|
function plainYearMonth(options = {}) {
|
|
235
258
|
const metavar = options.metavar ?? "YEAR-MONTH";
|
|
@@ -238,6 +261,7 @@ function plainYearMonth(options = {}) {
|
|
|
238
261
|
$mode: "sync",
|
|
239
262
|
metavar,
|
|
240
263
|
parse(input) {
|
|
264
|
+
ensureTemporal();
|
|
241
265
|
try {
|
|
242
266
|
const value = Temporal.PlainYearMonth.from(input);
|
|
243
267
|
return {
|
|
@@ -266,6 +290,8 @@ function plainYearMonth(options = {}) {
|
|
|
266
290
|
*
|
|
267
291
|
* @param options Configuration options for the plain month-day parser.
|
|
268
292
|
* @returns A ValueParser that parses strings into Temporal.PlainMonthDay values.
|
|
293
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
294
|
+
* at runtime.
|
|
269
295
|
*/
|
|
270
296
|
function plainMonthDay(options = {}) {
|
|
271
297
|
const metavar = options.metavar ?? "--MONTH-DAY";
|
|
@@ -274,6 +300,7 @@ function plainMonthDay(options = {}) {
|
|
|
274
300
|
$mode: "sync",
|
|
275
301
|
metavar,
|
|
276
302
|
parse(input) {
|
|
303
|
+
ensureTemporal();
|
|
277
304
|
try {
|
|
278
305
|
const value = Temporal.PlainMonthDay.from(input);
|
|
279
306
|
return {
|
|
@@ -304,6 +331,8 @@ function plainMonthDay(options = {}) {
|
|
|
304
331
|
*
|
|
305
332
|
* @param options Configuration options for the timezone parser.
|
|
306
333
|
* @returns A ValueParser that parses and validates timezone identifiers.
|
|
334
|
+
* @throws {TypeError} (from `parse()`) If the Temporal API is not available
|
|
335
|
+
* at runtime.
|
|
307
336
|
*/
|
|
308
337
|
function timeZone(options = {}) {
|
|
309
338
|
const metavar = options.metavar ?? "TIMEZONE";
|
|
@@ -312,6 +341,7 @@ function timeZone(options = {}) {
|
|
|
312
341
|
$mode: "sync",
|
|
313
342
|
metavar,
|
|
314
343
|
parse(input) {
|
|
344
|
+
ensureTemporal();
|
|
315
345
|
try {
|
|
316
346
|
Temporal.ZonedDateTime.from({
|
|
317
347
|
year: 2020,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optique/temporal",
|
|
3
|
-
"version": "1.0.0-dev.
|
|
3
|
+
"version": "1.0.0-dev.885+3300ebe1",
|
|
4
4
|
"description": "Temporal value parsers for Optique",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"CLI",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"sideEffects": false,
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@js-temporal/polyfill": "^0.5.1",
|
|
59
|
-
"@optique/core": "1.0.0-dev.
|
|
59
|
+
"@optique/core": "1.0.0-dev.885+3300ebe1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "^20.19.9",
|