@nmtjs/type 0.15.0-beta.52 → 0.15.0-beta.54
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/temporal/global.d.ts +2 -1
- package/dist/temporal/global.js +2 -1
- package/dist/temporal/global.js.map +1 -1
- package/dist/temporal/index.d.ts +9 -0
- package/dist/temporal/index.js +10 -0
- package/dist/temporal/index.js.map +1 -0
- package/dist/temporal/polyfill.d.ts +2 -1
- package/dist/temporal/polyfill.js +4 -1
- package/dist/temporal/polyfill.js.map +1 -1
- package/dist/types/temporal.d.ts +3 -0
- package/dist/types/temporal.js +14 -9
- package/dist/types/temporal.js.map +1 -1
- package/package.json +12 -8
- package/src/temporal/global.ts +5 -0
- package/src/temporal/index.ts +20 -0
- package/src/temporal/polyfill.ts +10 -0
- package/src/types/temporal.ts +21 -12
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType } from '../types/temporal.ts';
|
|
1
|
+
import { DurationType, InstantType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType } from '../types/temporal.ts';
|
|
2
2
|
export declare const plainDate: () => PlainDateType;
|
|
3
3
|
export declare const plainDatetime: () => PlainDateTimeType;
|
|
4
4
|
export declare const plainTime: () => PlainTimeType;
|
|
5
5
|
export declare const zonedDatetime: () => ZonedDateTimeType;
|
|
6
|
+
export declare const instant: () => InstantType;
|
|
6
7
|
export declare const duration: () => DurationType;
|
|
7
8
|
export declare const plainYearMonth: () => PlainYearMonthType;
|
|
8
9
|
export declare const plainMonthDay: () => PlainMonthDayType;
|
package/dist/temporal/global.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from '../types/temporal.js';
|
|
1
|
+
import { DurationType, InstantType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from '../types/temporal.js';
|
|
2
2
|
export const plainDate = PlainDateType.factory.bind(PlainDateType, globalThis.Temporal);
|
|
3
3
|
export const plainDatetime = PlainDateTimeType.factory.bind(PlainDateTimeType, globalThis.Temporal);
|
|
4
4
|
export const plainTime = PlainTimeType.factory.bind(PlainTimeType, globalThis.Temporal);
|
|
5
5
|
export const zonedDatetime = ZonedDateTimeType.factory.bind(ZonedDateTimeType, globalThis.Temporal);
|
|
6
|
+
export const instant = InstantType.factory.bind(InstantType, globalThis.Temporal);
|
|
6
7
|
export const duration = DurationType.factory.bind(DurationType, globalThis.Temporal);
|
|
7
8
|
export const plainYearMonth = PlainYearMonthType.factory.bind(PlainYearMonthType, globalThis.Temporal);
|
|
8
9
|
export const plainMonthDay = PlainMonthDayType.factory.bind(PlainMonthDayType, globalThis.Temporal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/temporal/global.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,CAAC,MAAM,SAAS,GAAwB,aAAa,CAAC,OAAO,CAAC,IAAI,CACtE,aAAa,EACb,UAAU,CAAC,QAAQ,CACpB,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GACxB,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;AACxE,MAAM,CAAC,MAAM,SAAS,GAAwB,aAAa,CAAC,OAAO,CAAC,IAAI,CACtE,aAAa,EACb,UAAU,CAAC,QAAQ,CACpB,CAAA;AACD,MAAM,CAAC,MAAM,aAAa,GACxB,iBAAiB,CAAC,OAA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MAAM,CAAC,MAAM,QAAQ,GAAuB,YAAY,CAAC,OAAO,CAAC,IAAI,CACnE,YAAY,EACZ,UAAU,CAAC,QAAQ,CACpB,CAAA;AACD,MAAM,CAAC,MAAM,cAAc,GACzB,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA;AAC1E,MAAM,CAAC,MAAM,aAAa,GACxB,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DurationType, InstantType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType } from '../types/temporal.ts';
|
|
2
|
+
export declare const plainDate: typeof PlainDateType.factory;
|
|
3
|
+
export declare const plainDatetime: typeof PlainDateTimeType.factory;
|
|
4
|
+
export declare const plainTime: typeof PlainTimeType.factory;
|
|
5
|
+
export declare const zonedDatetime: typeof ZonedDateTimeType.factory;
|
|
6
|
+
export declare const instant: typeof InstantType.factory;
|
|
7
|
+
export declare const duration: typeof DurationType.factory;
|
|
8
|
+
export declare const plainYearMonth: typeof PlainYearMonthType.factory;
|
|
9
|
+
export declare const plainMonthDay: typeof PlainMonthDayType.factory;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DurationType, InstantType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from '../types/temporal.js';
|
|
2
|
+
export const plainDate = PlainDateType.factory.bind(PlainDateType);
|
|
3
|
+
export const plainDatetime = PlainDateTimeType.factory.bind(PlainDateTimeType);
|
|
4
|
+
export const plainTime = PlainTimeType.factory.bind(PlainTimeType);
|
|
5
|
+
export const zonedDatetime = ZonedDateTimeType.factory.bind(ZonedDateTimeType);
|
|
6
|
+
export const instant = InstantType.factory.bind(InstantType);
|
|
7
|
+
export const duration = DurationType.factory.bind(DurationType);
|
|
8
|
+
export const plainYearMonth = PlainYearMonthType.factory.bind(PlainYearMonthType);
|
|
9
|
+
export const plainMonthDay = PlainMonthDayType.factory.bind(PlainMonthDayType);
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/temporal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;AAC9E,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;AAC9E,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;AAC5D,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;AAC/D,MAAM,CAAC,MAAM,cAAc,GACzB,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;AACrD,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType } from '../types/temporal.ts';
|
|
2
|
+
import { DurationType, InstantType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType } from '../types/temporal.ts';
|
|
3
3
|
export declare const plainDate: () => PlainDateType<typeof Temporal>;
|
|
4
4
|
export declare const plainDatetime: () => PlainDateTimeType<typeof Temporal>;
|
|
5
5
|
export declare const plainTime: () => PlainTimeType<typeof Temporal>;
|
|
6
6
|
export declare const zonedDatetime: () => ZonedDateTimeType<typeof Temporal>;
|
|
7
|
+
export declare const instant: () => InstantType<typeof Temporal>;
|
|
7
8
|
export declare const duration: () => DurationType<typeof Temporal>;
|
|
8
9
|
export declare const plainYearMonth: () => PlainYearMonthType<typeof Temporal>;
|
|
9
10
|
export declare const plainMonthDay: () => PlainMonthDayType<typeof Temporal>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from 'temporal-polyfill';
|
|
2
|
-
import { DurationType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from '../types/temporal.js';
|
|
2
|
+
import { DurationType, InstantType, PlainDateTimeType, PlainDateType, PlainMonthDayType, PlainTimeType, PlainYearMonthType, ZonedDateTimeType, } from '../types/temporal.js';
|
|
3
3
|
export const plainDate = PlainDateType.factory.bind(PlainDateType,
|
|
4
4
|
// @ts-expect-error
|
|
5
5
|
Temporal);
|
|
@@ -12,6 +12,9 @@ Temporal);
|
|
|
12
12
|
export const zonedDatetime = ZonedDateTimeType.factory.bind(ZonedDateTimeType,
|
|
13
13
|
// @ts-expect-error
|
|
14
14
|
Temporal);
|
|
15
|
+
export const instant = InstantType.factory.bind(InstantType,
|
|
16
|
+
// @ts-expect-error
|
|
17
|
+
Temporal);
|
|
15
18
|
export const duration = DurationType.factory.bind(DurationType,
|
|
16
19
|
// @ts-expect-error
|
|
17
20
|
Temporal);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../src/temporal/polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CACjD,aAAa;AACb,mBAAmB;AACnB,QAAQ,CAIT,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CACzD,iBAAiB;AACjB,mBAAmB;AACnB,QAAQ,CAIT,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CACjD,aAAa;AACb,mBAAmB;AACnB,QAAQ,CAIT,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CACzD,iBAAiB;AACjB,mBAAmB;AACnB,QAAQ,CAIT,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAC/C,YAAY;AACZ,mBAAmB;AACnB,QAAQ,CAIT,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAC3D,kBAAkB;AAClB,mBAAmB;AACnB,QAAQ,CAIT,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAAI,CACzD,iBAAiB;AACjB,mBAAmB;AACnB,QAAQ,CAIT,CAAA"}
|
|
1
|
+
{"version":3,"file":"polyfill.js","sourceRoot":"","sources":["../../src/temporal/polyfill.ts"],"names":[],"mappings":"AAAA,OA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
|
|
|
10
10
|
export declare class ZonedDateTimeType<T extends typeof Temporal = typeof Temporal> extends TransformType<InstanceType<T['ZonedDateTime']>, EncodeType> {
|
|
11
11
|
static factory<T extends typeof Temporal>(implementation: T): ZonedDateTimeType<T>;
|
|
12
12
|
}
|
|
13
|
+
export declare class InstantType<T extends typeof Temporal = typeof Temporal> extends TransformType<InstanceType<T['Instant']>, EncodeType> {
|
|
14
|
+
static factory<T extends typeof Temporal>(implementation: T): InstantType<T>;
|
|
15
|
+
}
|
|
13
16
|
export declare class PlainTimeType<T extends typeof Temporal = typeof Temporal> extends TransformType<InstanceType<T['PlainTime']>, EncodeType> {
|
|
14
17
|
static factory<T extends typeof Temporal>(implementation: T): PlainTimeType<T>;
|
|
15
18
|
}
|
package/dist/types/temporal.js
CHANGED
|
@@ -36,19 +36,24 @@ export class PlainDateTimeType extends TransformType {
|
|
|
36
36
|
}
|
|
37
37
|
export class ZonedDateTimeType extends TransformType {
|
|
38
38
|
static factory(implementation) {
|
|
39
|
-
const transformer = createTemporalTransformer(implementation, 'ZonedDateTime', (value) => implementation.
|
|
40
|
-
.withTimeZone('UTC')
|
|
41
|
-
.toString({
|
|
42
|
-
smallestUnit: 'milliseconds',
|
|
43
|
-
timeZoneName: 'never',
|
|
44
|
-
calendarName: 'never',
|
|
45
|
-
offset: 'never',
|
|
46
|
-
}) + 'Z');
|
|
39
|
+
const transformer = createTemporalTransformer(implementation, 'ZonedDateTime', (value) => implementation.ZonedDateTime.from(value), (value) => value.toString({ smallestUnit: 'microsecond' }));
|
|
47
40
|
return CustomType.factory({
|
|
48
41
|
decode: transformer.decode,
|
|
49
42
|
encode: transformer.encode,
|
|
43
|
+
type: string(),
|
|
44
|
+
error: 'Invalid zoned datetime format',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class InstantType extends TransformType {
|
|
49
|
+
static factory(implementation) {
|
|
50
|
+
const decode = (value) => implementation.Instant.from(value);
|
|
51
|
+
const encode = (value) => value.toJSON();
|
|
52
|
+
return CustomType.factory({
|
|
53
|
+
decode,
|
|
54
|
+
encode,
|
|
50
55
|
type: iso.datetime(),
|
|
51
|
-
error: 'Invalid
|
|
56
|
+
error: 'Invalid instant format',
|
|
52
57
|
});
|
|
53
58
|
}
|
|
54
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporal.js","sourceRoot":"","sources":["../../src/types/temporal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAE7C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAYvD,MAAM,yBAAyB,GAAG,CAChC,cAAiB,EACjB,IAAO,EACP,MAAM,GAAG,CAAC,KAAkC,EAAE,EAAE,CAAC;IAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;;QACjE,OAAO,KAAK,CAAA;AAAA,CAClB,EACD,MAAM,GAAG,CAAC,KAA+B,EAAE,EAAE,CAC3C,KAAK,CAAC,QAAQ,CAAC;IACb,YAAY,EAAE,OAAO;IACrB,YAAY,EAAE,aAAa;IAC3B,YAAY,EAAE,OAAO;CACtB,CAAC,EACJ,EAAE,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAA+B,CAAA;AAAA,CACvD,CAAA;AAID,MAAM,OAAO,aAEX,SAAQ,aAAuD;IAC/D,MAAM,CAAC,OAAO,CACZ,cAAiB,EACC;QAClB,MAAM,WAAW,GAAG,yBAAyB,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;QAC1E,OAAO,UAAU,CAAC,OAAO,CAA2C;YAClE,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE;YAChB,KAAK,EAAE,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M;YAC1B,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE;YACpB,KAAK,EAAE,yBAAyB;SACjC,CAAC,CAAA;IAAA,CACH;CACF;AAED,MAAM,OAAO,kBAEX,SAAQ,aAA4D;IACpE,MAAM,CAAC,OAAO,CACZ,cAAiB,EACM;QACvB,MAAM,WAAW,GAAG,yBAAyB,CAC3C,cAAc,EACd,gBAAgB,CACjB,CAAA;QACD,OAAO,UAAU,CAAC,OAAO,CAAgD;YACvE,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YAC5C,KAAK,EAAE,2BAA2B;SACnC,CAAC,CAAA;IAAA,CACH;CACF;AAED,MAAM,OAAO,iBAEX,SAAQ,aAA2D;IACnE,MAAM,CAAC,OAAO,CACZ,cAAiB,EACK;QACtB,MAAM,WAAW,GAAG,yBAAyB,CAC3C,cAAc,EACd,eAAe,CAChB,CAAA;QACD,OAAO,UAAU,CAAC,OAAO,CAA+C;YACtE,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;YAC5C,KAAK,EAAE,0BAA0B;SAClC,CAAC,CAAA;IAAA,CACH;CACF"}
|
package/package.json
CHANGED
|
@@ -20,36 +20,40 @@
|
|
|
20
20
|
"module-sync": "./dist/types/*.js"
|
|
21
21
|
},
|
|
22
22
|
"./temporal": {
|
|
23
|
+
"types": "./dist/temporal/index.d.ts",
|
|
24
|
+
"import": "./dist/temporal/index.js",
|
|
25
|
+
"module-sync": "./dist/temporal/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./temporal/global": {
|
|
23
28
|
"types": "./dist/temporal/global.d.ts",
|
|
24
29
|
"import": "./dist/temporal/global.js",
|
|
25
30
|
"module-sync": "./dist/temporal/global.js"
|
|
26
31
|
},
|
|
27
|
-
"./temporal
|
|
32
|
+
"./temporal/polyfill": {
|
|
28
33
|
"types": "./dist/temporal/polyfill.d.ts",
|
|
29
34
|
"import": "./dist/temporal/polyfill.js",
|
|
30
35
|
"module-sync": "./dist/temporal/polyfill.js"
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"dependencies": {
|
|
34
|
-
"@standard-schema/spec": "^1.1.0"
|
|
35
|
-
"temporal-spec": "^0.3.0"
|
|
39
|
+
"@standard-schema/spec": "^1.1.0"
|
|
36
40
|
},
|
|
37
41
|
"peerDependencies": {
|
|
38
|
-
"temporal-polyfill": "^0.3.
|
|
42
|
+
"temporal-polyfill": "^0.3.2",
|
|
39
43
|
"zod": "^4.3.5",
|
|
40
|
-
"@nmtjs/common": "0.15.0-beta.
|
|
44
|
+
"@nmtjs/common": "0.15.0-beta.54"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
|
-
"temporal-polyfill": "^0.3.
|
|
47
|
+
"temporal-polyfill": "^0.3.2",
|
|
44
48
|
"zod": "^4.3.5",
|
|
45
|
-
"@nmtjs/common": "0.15.0-beta.
|
|
49
|
+
"@nmtjs/common": "0.15.0-beta.54"
|
|
46
50
|
},
|
|
47
51
|
"peerDependenciesMeta": {
|
|
48
52
|
"temporal-polyfill": {
|
|
49
53
|
"optional": true
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
|
-
"version": "0.15.0-beta.
|
|
56
|
+
"version": "0.15.0-beta.54",
|
|
53
57
|
"scripts": {
|
|
54
58
|
"clean-build": "rm -rf ./dist"
|
|
55
59
|
}
|
package/src/temporal/global.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DurationType,
|
|
3
|
+
InstantType,
|
|
3
4
|
PlainDateTimeType,
|
|
4
5
|
PlainDateType,
|
|
5
6
|
PlainMonthDayType,
|
|
@@ -20,6 +21,10 @@ export const plainTime: () => PlainTimeType = PlainTimeType.factory.bind(
|
|
|
20
21
|
)
|
|
21
22
|
export const zonedDatetime: () => ZonedDateTimeType =
|
|
22
23
|
ZonedDateTimeType.factory.bind(ZonedDateTimeType, globalThis.Temporal)
|
|
24
|
+
export const instant: () => InstantType = InstantType.factory.bind(
|
|
25
|
+
InstantType,
|
|
26
|
+
globalThis.Temporal,
|
|
27
|
+
)
|
|
23
28
|
export const duration: () => DurationType = DurationType.factory.bind(
|
|
24
29
|
DurationType,
|
|
25
30
|
globalThis.Temporal,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DurationType,
|
|
3
|
+
InstantType,
|
|
4
|
+
PlainDateTimeType,
|
|
5
|
+
PlainDateType,
|
|
6
|
+
PlainMonthDayType,
|
|
7
|
+
PlainTimeType,
|
|
8
|
+
PlainYearMonthType,
|
|
9
|
+
ZonedDateTimeType,
|
|
10
|
+
} from '../types/temporal.ts'
|
|
11
|
+
|
|
12
|
+
export const plainDate = PlainDateType.factory.bind(PlainDateType)
|
|
13
|
+
export const plainDatetime = PlainDateTimeType.factory.bind(PlainDateTimeType)
|
|
14
|
+
export const plainTime = PlainTimeType.factory.bind(PlainTimeType)
|
|
15
|
+
export const zonedDatetime = ZonedDateTimeType.factory.bind(ZonedDateTimeType)
|
|
16
|
+
export const instant = InstantType.factory.bind(InstantType)
|
|
17
|
+
export const duration = DurationType.factory.bind(DurationType)
|
|
18
|
+
export const plainYearMonth =
|
|
19
|
+
PlainYearMonthType.factory.bind(PlainYearMonthType)
|
|
20
|
+
export const plainMonthDay = PlainMonthDayType.factory.bind(PlainMonthDayType)
|
package/src/temporal/polyfill.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Temporal } from 'temporal-polyfill'
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
DurationType,
|
|
5
|
+
InstantType,
|
|
5
6
|
PlainDateTimeType,
|
|
6
7
|
PlainDateType,
|
|
7
8
|
PlainMonthDayType,
|
|
@@ -46,6 +47,15 @@ export const zonedDatetime = ZonedDateTimeType.factory.bind(
|
|
|
46
47
|
typeof Temporal
|
|
47
48
|
>
|
|
48
49
|
|
|
50
|
+
export const instant = InstantType.factory.bind(
|
|
51
|
+
InstantType,
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
Temporal,
|
|
54
|
+
) as () => InstantType<
|
|
55
|
+
// @ts-expect-error
|
|
56
|
+
typeof Temporal
|
|
57
|
+
>
|
|
58
|
+
|
|
49
59
|
export const duration = DurationType.factory.bind(
|
|
50
60
|
DurationType,
|
|
51
61
|
// @ts-expect-error
|
package/src/types/temporal.ts
CHANGED
|
@@ -76,26 +76,35 @@ export class ZonedDateTimeType<
|
|
|
76
76
|
const transformer = createTemporalTransformer(
|
|
77
77
|
implementation,
|
|
78
78
|
'ZonedDateTime',
|
|
79
|
-
(value) => implementation.
|
|
80
|
-
(value) =>
|
|
81
|
-
value
|
|
82
|
-
.withTimeZone('UTC')
|
|
83
|
-
.toString({
|
|
84
|
-
smallestUnit: 'milliseconds',
|
|
85
|
-
timeZoneName: 'never',
|
|
86
|
-
calendarName: 'never',
|
|
87
|
-
offset: 'never',
|
|
88
|
-
}) + 'Z',
|
|
79
|
+
(value) => implementation.ZonedDateTime.from(value),
|
|
80
|
+
(value) => value.toString({ smallestUnit: 'microsecond' }),
|
|
89
81
|
)
|
|
90
82
|
return CustomType.factory<InstanceType<T['ZonedDateTime']>, EncodeType>({
|
|
91
83
|
decode: transformer.decode,
|
|
92
84
|
encode: transformer.encode,
|
|
93
|
-
type:
|
|
94
|
-
error: 'Invalid datetime format',
|
|
85
|
+
type: string(),
|
|
86
|
+
error: 'Invalid zoned datetime format',
|
|
95
87
|
})
|
|
96
88
|
}
|
|
97
89
|
}
|
|
98
90
|
|
|
91
|
+
export class InstantType<
|
|
92
|
+
T extends typeof Temporal = typeof Temporal,
|
|
93
|
+
> extends TransformType<InstanceType<T['Instant']>, EncodeType> {
|
|
94
|
+
static factory<T extends typeof Temporal>(implementation: T): InstantType<T> {
|
|
95
|
+
const decode = (value: string) =>
|
|
96
|
+
implementation.Instant.from(value) as InstanceType<T['Instant']>
|
|
97
|
+
const encode = (value: InstanceType<T['Instant']>) => value.toJSON()
|
|
98
|
+
|
|
99
|
+
return CustomType.factory<InstanceType<T['Instant']>, EncodeType>({
|
|
100
|
+
decode,
|
|
101
|
+
encode,
|
|
102
|
+
type: iso.datetime(),
|
|
103
|
+
error: 'Invalid instant format',
|
|
104
|
+
}) as InstantType<T>
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
99
108
|
export class PlainTimeType<
|
|
100
109
|
T extends typeof Temporal = typeof Temporal,
|
|
101
110
|
> extends TransformType<InstanceType<T['PlainTime']>, EncodeType> {
|