Bug: Units must be a number
alessioalex opened this issue · 5 comments
How to replicate:
new timezoneJS.Date(2014, 2, 11, 13, 0, 'Europe/Samara').toISOString()
Note: this can be usually replicated when using timezones with >= +03:00 GMT
So far it has come down to the following line (in the setTimezone function):
this.setUTCMinutes(this.getUTCMinutes() - this.getTimezoneInfo().tzOffset + previousOffset);
When I console logged the info it seems previousOffset
is a String instead of a Number, so if you do 0 + '-240'
it will equal '0-240'
.
I'm not sure why it's a String and not a Number, but a quick fix is to turn previousOffset
into a Number, like so:
this.setUTCMinutes(this.getUTCMinutes() - this.getTimezoneInfo().tzOffset + Number(previousOffset));
Could you put this in a PR, with the relevant test?
@mde certainly. I would like to digg in more into the cause, so it will take me a couple of days before I submit it.
If it can help, I've had the same problem for dates in zone Europe/Paris before 25/12/1979 or something.
I just ran into this when loading the pre-parsed Olson data.