sigo-entities 0.0.180 → 0.0.181
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.js +6 -3
- package/dist/index.mjs +6 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -336,9 +336,12 @@ function formatErrors(errors, parentPath = "") {
|
|
|
336
336
|
|
|
337
337
|
// src/shared/utils/convertStringsToDates.ts
|
|
338
338
|
function convertStringsToDates(obj) {
|
|
339
|
-
|
|
340
|
-
const date = new Date(
|
|
341
|
-
return isNaN(date.getTime())
|
|
339
|
+
const isValidDate = (str) => {
|
|
340
|
+
const date = new Date(str);
|
|
341
|
+
return !isNaN(date.getTime()) && str === date.toISOString();
|
|
342
|
+
};
|
|
343
|
+
if (typeof obj === "string" && isValidDate(obj)) {
|
|
344
|
+
return new Date(obj);
|
|
342
345
|
}
|
|
343
346
|
if (Array.isArray(obj)) {
|
|
344
347
|
return obj.map((item) => convertStringsToDates(item));
|
package/dist/index.mjs
CHANGED
|
@@ -97,9 +97,12 @@ function formatErrors(errors, parentPath = "") {
|
|
|
97
97
|
|
|
98
98
|
// src/shared/utils/convertStringsToDates.ts
|
|
99
99
|
function convertStringsToDates(obj) {
|
|
100
|
-
|
|
101
|
-
const date = new Date(
|
|
102
|
-
return isNaN(date.getTime())
|
|
100
|
+
const isValidDate = (str) => {
|
|
101
|
+
const date = new Date(str);
|
|
102
|
+
return !isNaN(date.getTime()) && str === date.toISOString();
|
|
103
|
+
};
|
|
104
|
+
if (typeof obj === "string" && isValidDate(obj)) {
|
|
105
|
+
return new Date(obj);
|
|
103
106
|
}
|
|
104
107
|
if (Array.isArray(obj)) {
|
|
105
108
|
return obj.map((item) => convertStringsToDates(item));
|