Closed divide0 closed 11 years ago
What exactly is the issue here? Is it related to issue #37? Can you provide some codes to reproduce the bug?
The issue is that it doesn't adjust the time for dst.
In the tz def: 13:00 1:00 WSDT 2012 Apr 1 4:00
It has an offset of +13 and a static DST offset of +1 (not a rule reference), so the effective offset for times in dst shoudl be +14, but it is +13.
This happens because timezone-js only uses rules by reference. It doesn't find a rule for "1:00", so it doesn't apply any DST offset.
var dt = new timezoneJS.Date(Date.UTC(2012, 2, 1, 0, 0, 0, 0), "Pacific/Apia");
console.log("Time (should be 14:00:00): " + dt.toString("EEE, dd MMM yyyy HH:mm:ss Z"));
console.log("Offset in Hours (should be -14 hours): " + dt.getTimezoneOffset() / 60);
LOG: Time (should be 14:00:00): Thu, 01 Mar 2012 13:00:00 WSDT
LOG: Offset in Hours (should be -14 hours): -13
Gotcha! Thanks for the clarification I'll take a look at this
I found this great resource for the timezone files (don't be scared by the sketchy IP link) that gives a good description of static offsets:
The RULES column tells us whether daylight saving time is being observed:
- A hyphen, a kind of null value, means that we have not set our clocks ahead of standard time.
- An amount of time (usually but not necessarily “1:00” meaning one hour) means that we have set our clocks ahead by that amount.
- Some alphabetic string means that we might have set our clocks ahead; and we need to check the rule the name of which is the given alphabetic string.
An example of a specific amount of time is:
Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Honolulu ... 1933 Apr 30 2:00 -10:30 1:00 HDT 1933 May 21 2:00 ...
Hawaii tried daylight saving time for three weeks in 1933 and decided they didn’t like it. 8-) Note that the GMTOFF column always contains the standard time offset, so the wall clock time during this period was GMT − 10:30 + 1:00 = GMT − 9:30.
lol thanks :) it's kinda tricky since some of the rules are in local time, which is the time we're trying to retrieve for certain zones so it gets confusing.
this can be closed with the recent pull.
Example is Pacific/Apia, in the australasia file
Notice that instead of referencing DST rules, they just put the DST offset.