I have attempted to upgrade to the latest version of jsTimezoneDetect from a version dated 1/19/12 and noticed a fair amount of backwards incompatible changes that are not documented anywhere.
Specifically, this script used to return the name of the user timezone, the offset and whether or not it is subject to DST. Now, it returns only the name.
To compound matters, I wasn't able to figure out any way to get the timezone offset from the script, even though it still seems capable of doing so. If I modify the script to expose "lookup_key" as a public method, I can get the offset via:
var offset = jstz.lookup_key(jstz.determine().name()).split(',')
This gives me an offset that is close to what the script previously returned, but in the wrong format. Previously, the offset would be in the format -05:00 and now it's -300. With some more string manipulation, I can get it to where I need it to be.
This brings up several questions: 1) Why was the script changed to no longer return this data? The script seems much less useful now. 2) Am I missing something or is the only way to get this data to make a local modification to add lookup_key as a publicly exposed method? Any reason this method can't be exposed? 3) MINOR TYPO: The "determine_timezone" method was apparently replaced with "determine" but is still referenced in a comment on line 278. 4) How about restoring determine_timezone() to preserve the original behavior but also trigger a deprecation warning via:
if (console && console.warn) console.warn('determine_timezone is deprecated');
I believe this is how other projects handle changing APIs. This would enable backwards compatibility while steering people toward using the new API.
5) I'm unclear on what the original behavior of the timezone.dst flag was in the earlier version of the script. Since I need this value back, is it better to infer this value from:
Out of curiosity, what, if any, is the difference between the two?