We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cd98b1c commit e75768cCopy full SHA for e75768c
src/DateInput.jsx
@@ -24,6 +24,14 @@ const defaultMaxDate = new Date(8.64e15);
24
const allViews = ['century', 'decade', 'year', 'month'];
25
const allValueTypes = [...allViews.slice(1), 'day'];
26
27
+function toDate(value) {
28
+ if (value instanceof Date) {
29
+ return value;
30
+ }
31
+
32
+ return new Date(value);
33
+}
34
35
function datesAreDifferent(date1, date2) {
36
return (
37
(date1 && !date2)
@@ -50,7 +58,7 @@ function getValue(value, index) {
50
58
return null;
51
59
}
52
60
53
- const valueDate = new Date(rawValue);
61
+ const valueDate = toDate(rawValue);
54
62
55
63
if (isNaN(valueDate.getTime())) {
56
64
throw new Error(`Invalid date: ${value}`);
0 commit comments