Gillardo / bootstrap-ui-datetime-picker

AngularJs directive to allow use of the bootstrap UI date/time pickers in a single dropdown
MIT License
306 stars 168 forks source link

Date parsing in Safari prevents passing a default-time by the directive #221

Closed djuerges closed 6 years ago

djuerges commented 6 years ago

There is a difference in date parsing between Safari and other browsers.

https://stackoverflow.com/questions/6427204/date-parsing-in-javascript-is-different-between-safari-and-chrome#6427318

Setting a default-time by argument of the directive will lead to an invalid date exception in 2.6.1 line 367 on parsing the date with the added default time:

var t = new Date('2001-01-01 ' + defaultTime);

screen shot 2018-04-06 at 11 21 26

However if you see https://stackoverflow.com/questions/4310953/invalid-date-in-safari there is a simple fix for it:

new Date('2001/01/01 ' + defaultTime) will output to Mon Jan 01 2001 12:00:00 GMT+0100 (CET)

If the problem persist on other parts of the code as well, there is a more general approach to use .replace(/-/g, "/"). But I haven't found any other occurrence yet.