Skip to content

Commit b7492fc

Browse files
committed
Use strict date parsing when the input changes value
Found a bug where `2014--01` would convert to `2014-01-01` which made the input pretty much unusable, so I decided to turn on strict parsing. The date is now only selected if the date strictly matches `YYYY-MM-DD`
1 parent 2c9fd79 commit b7492fc

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

react-datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ var DatePicker = React.createClass({displayName: 'DatePicker',
179179
},
180180

181181
handleInputChange: function(event) {
182-
var date = moment(event.target.value, "YYYY-MM-DD");
182+
var date = moment(event.target.value, "YYYY-MM-DD", true);
183183

184184
this.setState({
185185
value: event.target.value

src/datepicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ var DatePicker = React.createClass({
7979
},
8080

8181
handleInputChange: function(event) {
82-
var date = moment(event.target.value, "YYYY-MM-DD");
82+
var date = moment(event.target.value, "YYYY-MM-DD", true);
8383

8484
this.setState({
8585
value: event.target.value

0 commit comments

Comments
 (0)