mde / timezone-js

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

The constructor with year, month and tz returns different result from constructor for Date #114

Closed shosokawa closed 10 years ago

shosokawa commented 10 years ago

Date:

new Date( 2011, 8).getMonth()
8

timezoneJS.Date:

new timezoneJS.Date( 2011, 8, 'Etc/UTC').getMonth()
7

I suppose that cause of this problem is reason why arguments are filled by 0 if arguments except tz are more than 1. It runs new Date( 2011, 8, 0, 0...), that might be new Date( 2011, 8, 1, 0...) for same result for Date.

mde commented 10 years ago

When passing just the year, do we also get the same sort of inconsistent result?

shosokawa commented 10 years ago

I don't think so. Because in the case of one argument as Integer, it is processed as milliseconds.

mde commented 10 years ago

Excellent, just want to avoid having even more special-casing in there. The code is pretty ugly as it is. Could you add a test for this along with your fix?

shosokawa commented 10 years ago

I added a test for the fix.