Timezones whoops in Iphone and Safari with Daylight Savings
Looping through October dates in 2015 for Sydney Australia, I was finding it weird that I had 32 days ! I'm fairly sure that wasn't how the rhyme went.
Anyway, looking into it, turned out that when starting at 1/10/2015 and adding 1 day til the end of the month, you ended up with 1,2,3,3,4 - see an extra day there which seems like Sat showed up twice.
Turns out, there appears to be a big in the "Spring Forward" part of the Javascript engin there where Midnight on 4/10/2015 is interpreted as actually being 3/10/2015 at 23:00, go figure.
In reverse, 5/4/2015 ("Fall Back") was displayed as 5/4/2015 at 1AM!!!!
See the quirks below which appears in Chrome; try on an iPhone to see for yourself.
Of course it was already asked over there on at stackoverflow.
Script to produce this is:
<table border="1">
<tr><td>Date</td><td>TimeZone Offset</td><td>Month</td><td>Day Of Month</td><td>Time</td><td>UTC Hours</td></tr>
<script>
var d = new Date(2015,3,5, 0,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,3,5, 1,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,3,5, 2,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,3,5, 3,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,3,5, 4,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 0,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 1,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 2,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 3,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 4,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 0,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 1,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 2,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 3,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 4,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
</script>
</table>
Anyway, looking into it, turned out that when starting at 1/10/2015 and adding 1 day til the end of the month, you ended up with 1,2,3,3,4 - see an extra day there which seems like Sat showed up twice.
Turns out, there appears to be a big in the "Spring Forward" part of the Javascript engin there where Midnight on 4/10/2015 is interpreted as actually being 3/10/2015 at 23:00, go figure.
In reverse, 5/4/2015 ("Fall Back") was displayed as 5/4/2015 at 1AM!!!!
See the quirks below which appears in Chrome; try on an iPhone to see for yourself.
Of course it was already asked over there on at stackoverflow.
Date | TimeZone Offset | Month | Day Of Month | Time | UTC Hours | |
Sun Apr 05 2015 00:00:00 GMT+1100 (AUS Eastern Daylight Time) | -660 | 3 | 5 | 1428152400000 | 13 | |
Sun Apr 05 2015 01:00:00 GMT+1100 (AUS Eastern Daylight Time) | -660 | 3 | 5 | 1428156000000 | 14 | |
Sun Apr 05 2015 02:00:00 GMT+1100 (AUS Eastern Daylight Time) | -660 | 3 | 5 | 1428159600000 | 15 | |
Sun Apr 05 2015 03:00:00 GMT+1000 (AUS Eastern Standard Time) | -600 | 3 | 5 | 1428166800000 | 17 | |
Sun Apr 05 2015 04:00:00 GMT+1000 (AUS Eastern Standard Time) | -600 | 3 | 5 | 1428170400000 | 18 | |
Sun Oct 04 2015 00:00:00 GMT+1000 (AUS Eastern Standard Time) | -600 | 9 | 4 | 1443880800000 | 14 | |
Sun Oct 04 2015 01:00:00 GMT+1000 (AUS Eastern Standard Time) | -600 | 9 | 4 | 1443884400000 | 15 | |
Sun Oct 04 2015 03:00:00 GMT+1100 (AUS Eastern Daylight Time) | -660 | 9 | 4 | 1443888000000 | 16 | |
Sun Oct 04 2015 03:00:00 GMT+1100 (AUS Eastern Daylight Time) | -660 | 9 | 4 | 1443888000000 | 16 | |
Sun Oct 04 2015 04:00:00 GMT+1100 (AUS Eastern Daylight Time) | -660 | 9 | 4 | 1443891600000 | 17 |
Script to produce this is:
<table border="1">
<tr><td>Date</td><td>TimeZone Offset</td><td>Month</td><td>Day Of Month</td><td>Time</td><td>UTC Hours</td></tr>
<script>
var d = new Date(2015,3,5, 0,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,3,5, 1,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,3,5, 2,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,3,5, 3,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,3,5, 4,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 0,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 1,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 2,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 3,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2015,9,4, 4,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 0,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 1,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 2,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 3,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
var d = new Date(2016,3,3, 4,0,0);// Oct
document.write("<tr><td>" + d + "</td><td>" + d.getTimezoneOffset() + "</td><td>" + d.getMonth() + "</td><td>"+ d.getDate() + "</td><td>"+ d.getTime() + "</td><td>"+ d.getUTCHours() + "</td></tr>");
</script>
</table>
Comments
Post a Comment