@naturalcycles/js-lib 14.139.2 → 14.139.3
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.
|
@@ -51,7 +51,7 @@ class LocalDate {
|
|
|
51
51
|
if (d instanceof LocalDate)
|
|
52
52
|
return d;
|
|
53
53
|
// const [year, month, day] = d.slice(0, 10).split('-').map(Number)
|
|
54
|
-
const matches = DATE_REGEX.exec(d.slice(0, 10));
|
|
54
|
+
const matches = typeof d === 'string' && DATE_REGEX.exec(d.slice(0, 10));
|
|
55
55
|
if (!matches)
|
|
56
56
|
return null;
|
|
57
57
|
const year = Number(matches[1]);
|
|
@@ -48,7 +48,7 @@ export class LocalDate {
|
|
|
48
48
|
if (d instanceof LocalDate)
|
|
49
49
|
return d;
|
|
50
50
|
// const [year, month, day] = d.slice(0, 10).split('-').map(Number)
|
|
51
|
-
const matches = DATE_REGEX.exec(d.slice(0, 10));
|
|
51
|
+
const matches = typeof d === 'string' && DATE_REGEX.exec(d.slice(0, 10));
|
|
52
52
|
if (!matches)
|
|
53
53
|
return null;
|
|
54
54
|
const year = Number(matches[1]);
|
package/package.json
CHANGED
|
@@ -69,7 +69,7 @@ export class LocalDate {
|
|
|
69
69
|
if (d instanceof LocalDate) return d
|
|
70
70
|
|
|
71
71
|
// const [year, month, day] = d.slice(0, 10).split('-').map(Number)
|
|
72
|
-
const matches = DATE_REGEX.exec(d.slice(0, 10))
|
|
72
|
+
const matches = typeof (d as any) === 'string' && DATE_REGEX.exec(d.slice(0, 10))
|
|
73
73
|
if (!matches) return null
|
|
74
74
|
|
|
75
75
|
const year = Number(matches[1])
|
|
@@ -82,6 +82,9 @@ export class LocalTime {
|
|
|
82
82
|
date = d
|
|
83
83
|
} else if (typeof d === 'number') {
|
|
84
84
|
date = new Date(d * 1000)
|
|
85
|
+
} else if (typeof (d as any) !== 'string') {
|
|
86
|
+
// unexpected type, e.g Function or something
|
|
87
|
+
return null
|
|
85
88
|
} else {
|
|
86
89
|
date = new Date(d.slice(0, 19))
|
|
87
90
|
}
|