@loomcore/common 0.0.52 → 0.0.53
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.
|
@@ -38,9 +38,13 @@ export function TypeboxIsoDate(options = {}) {
|
|
|
38
38
|
const dateTransform = Type.Transform(Type.String({ format: 'date-time', ...options }))
|
|
39
39
|
.Decode(value => new Date(value))
|
|
40
40
|
.Encode(value => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
if (value instanceof Date)
|
|
42
|
+
return value.toISOString();
|
|
43
|
+
if (typeof value === 'string')
|
|
44
|
+
return value;
|
|
45
|
+
if (typeof value === 'number')
|
|
46
|
+
return new Date(value).toISOString();
|
|
47
|
+
return value;
|
|
44
48
|
});
|
|
45
49
|
return dateTransform;
|
|
46
50
|
}
|
|
@@ -52,9 +56,18 @@ export function TypeboxDate(options = {}) {
|
|
|
52
56
|
return date;
|
|
53
57
|
})
|
|
54
58
|
.Encode(value => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
if (value instanceof Date) {
|
|
60
|
+
value.setUTCHours(0, 0, 0, 0);
|
|
61
|
+
return value.toISOString();
|
|
62
|
+
}
|
|
63
|
+
if (typeof value === 'string')
|
|
64
|
+
return value;
|
|
65
|
+
if (typeof value === 'number') {
|
|
66
|
+
const date = new Date(value);
|
|
67
|
+
date.setUTCHours(0, 0, 0, 0);
|
|
68
|
+
return date.toISOString();
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
58
71
|
});
|
|
59
72
|
return dateTransform;
|
|
60
73
|
}
|
package/package.json
CHANGED