1. Jon Nylander
  2. jsTimezoneDetect
  3. Issues


Issue #35 invalid

Timezone offset wrong

Anonymous 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 repo owner

    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