smalot / bootstrap-datetimepicker

Both Date and Time picker widget based on twitter bootstrap (supports Bootstrap v2 and v3)
http://www.malot.fr/bootstrap-datetimepicker/
Apache License 2.0
3.49k stars 1.65k forks source link

Unparsable Date should default to today's date, not Dec. 31 1899 #693

Open abcbaby opened 6 years ago

abcbaby commented 6 years ago

Should update boostrap-datetimepicker.js parseDate().

Currently the date is set to:

date = new Date(0, 0, 0, 0, 0, 0, 0), // which is Dec. 31, 1899

change to:

date = new Date(), // which is today's date

This should resolve a bunch of current reported 1899 Year issues: https://github.com/smalot/bootstrap-datetimepicker/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%201899

mholmes-hs commented 6 years ago

I agree with this. My app allows the user to switch field types on a table filter. We've seen an issue where we saw the 1899 when a stale date M dd, yyyy was present when the user loaded date time format M dd, yyyy HH:ii p.

Had to call reset as a fix, but it would have nice to have this.

Or an else statement to if (parts.length === format.parts.length) { that falls back on a new date object

adamzolotarev commented 6 years ago

It would be nice if it was possible to pass the default reset date as an option for unparsable dates