Issues

Issue #35 invalid

Timezone offset wrong

Anonymous avatarAnonymous created an issue
  • what timezone your computer is set to:

GMT+1 with DST

  • what operating system you use:

Mac OS X Lion

  • what browser you use:

Chrome 18.0.1025.151

I ran the following code:

var timezone = jstz.determine_timezone();
console.log(timezone.offset());

This returns +01:00 instead of +02:00 because of the daylight saving time in effect. If you don't agree with me that this is a bug, how do I safely get the offset with DST? Because adding +01:00 to the time isn't correct according to Wikipedia:

 A one-hour shift is customary, but Australia's Lord Howe Island uses a half-hour shift.[34] Twenty-minute and two-hour shifts have been used in the past.

http://en.wikipedia.org/wiki/Daylight_saving_time#Procedure

Kind regards, Mark

Comments (1)

  1. Jon Nylander

    You're expecting the offset to be +2? I understand that. But that is not what this script does. It gives you

    • the name of the time zone you are in (or the name of an identical time zone),
    • the offset when the time zone is NOT in DST and, (i.e the offset commonly used to identify your time zone) and
    • information about whether the time zone uses DST or not (true if you do, false if you dont)

    If you want the current offset from UTC you can simply use this:

    (new Date()).getTimezoneOffset();
    

    So getting the current offset is trivial. Finding out which timezone you are in is not.

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.