I've recently come across a problem...
Lets say I have some Javascript like this, for example:
var timezone = -(new Date()).getTimezoneOffset() / 60; // Get the TZ offset
var local = [];
var gmt = [];
for(var i = 0; i <= 23; i++) // Loop through each hour
{
local.push(i);
var time = (i + timezone);
if(time == 24)
time = 0;
gmt.push(time);
}
This works perfectly while not in DST, but when DST comes around I have unexpected results such as this: (Local user is in GMT/DST)
> console.log(local);
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
> console.log(gmt);
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0]
Where the two arrays should be the same.
How would I detect when Daylight Saving is in effect?