trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

splitDateTime failing #763

Open glittle opened 9 years ago

glittle commented 9 years ago

Using version 1.5.0

While processing in splitDateTime, the date string is not parsed correctly. I debugged and stopped it when returning. Here is what I find:

dateTimeString: "Mon Sep 29 2014 13:01:42 GMT-0600 (Mountain Daylight Time)"
format: "h:mm tt"
allParts: Array[9]
0: "Mon"
1: "Sep"
2: "29"
3: "2014"
4: "13:01:42"
5: "GMT-0600"
6: "(Mountain"
7: "Daylight"
8: "Time)"

// return values:
dateString: "Mon Sep 29 2014 13:01:42 GMT-0600 (Mountain"
timeString: "Daylight Time)"

Because the time format only has two parts, it is only using the last two parts of the dateTimeString. I can't change the time format, because that's how I want the time displayed.

Would it not be better to use .getHours(), .getMinutes() etc. to split the input date into day and time? It seems that the current method is at the mercy of how each browser might format the date string.