mde / timezone-js

DEPRECATED: Timezone-enabled JavaScript Date object. Uses Olson zoneinfo files for timezone data.
824 stars 183 forks source link

setHours doesn't match the native JS date object spec #48

Closed m5m1th closed 11 years ago

m5m1th commented 12 years ago

Hello, the native JS Date setHours method has the following signature: setHours(hoursValue[, minutesValue[, secondsValue[, msValue]]]) but timezonejs ignores all parameters after hoursValue: setHours: function (n)

setFullYear similarly ignores everything after the first parameter.

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setHours http://www.w3schools.com/jsref/jsref_sethours.asp

longlho commented 12 years ago

Cool I'll take a look at this.

stephenliberty commented 11 years ago

Setting "0" is falsey, which won't follow through properly in that commit. So, trying to do something like "setHours(12, 0, 0, 0)" for 12 o'clock sharp will leave it as 12 for the hour, and whatever the minutes/seconds/milliseconds were on creation. Easy fix is just using the !== undefined like was done on the setFullYear.