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 be0e9cc commit 7a61215Copy full SHA for 7a61215
src/Calendar.jsx
@@ -25,6 +25,14 @@ const baseClassName = 'react-calendar';
25
const allViews = ['century', 'decade', 'year', 'month'];
26
const allValueTypes = [...allViews.slice(1), 'day'];
27
28
+function toDate(value) {
29
+ if (value instanceof Date) {
30
+ return value;
31
+ }
32
+
33
+ return new Date(value);
34
+}
35
36
/**
37
* Returns views array with disallowed values cut off.
38
*/
@@ -71,7 +79,7 @@ function getValue(value, index) {
71
79
return null;
72
80
}
73
81
74
- const valueDate = new Date(rawValue);
82
+ const valueDate = toDate(rawValue);
75
83
76
84
if (isNaN(valueDate.getTime())) {
77
85
throw new Error(`Invalid date: ${value}`);
0 commit comments