1. Jon Nylander
  2. jsTimezoneDetect
  3. Issues


Issue #64 new

Incorrect Middle-Eastern Timezones

John Foley
created an issue


I am currently using your script and have noticed some discrepancies when I have my timezone set to certain middle eastern locations. The discrepancy is between unix and windows operating systems. For Example: When I have my timezone set to 'Asia/Jerusalem' I start running through AMBIGUITIES array for 'Asia/Beirut'. While in Unix the first 4 values in this array return a getTimezoneOffset() value of 240 - which is equal to the January offset that this value is compared to - and therefore moves on to the next item in the array. Finally, ( still in unix ) we test the 5th value in the array, 'Asia/Jerusalem', and its getTimezoneOffset() comes back with 300, different than January offsets 240 value - so it is decided that is the correct location, and ultimately returns the location as "ISRAEL". This is working perfectly, and is exactly what we had hoped to find at my company.

However, in Windows, the first value in the 'Asia/Beirut' slot of the AMBIGUITIES array (which is Asia/Beirut) comes back with a getTimezoneOffset() value of 300, which causes the script to believe this is the correct location, and ultimately determines our location as being "PAKISTAN".

To remedy this - have changed the New Date() values for the first 4 locations in the array discussed above by incrementing the month by 1.

Have you found this issue before ? Do you believe my solution is valid ?

I will attach my modified script.

Please email me at jfoley@timetrade.com

Thank you

Comments (9)

  1. Nils Kilden-Pedersen

    Matt, read the docs: "if you are unhappy with the time zone "Europe/Berlin" when the user is in fact in "Europe/Stockholm" - this script is not for you. (They are both identical in modern time)."

  2. Jon Nylander repo owner

    Hey all.

    I do actually try to distinguish between Asia/Beirut and Asia/Jerusalem. Hopefully I will be able to resolve this in 1.0.5. But testing is hard on all different platforms with differently updated timezone databases.

    Fortunately Beirut and Jerusalem are extremely similar time zones. I am more concerned with Karachi turning up as John mentions. I can't reproduce that. But I'll try again when I have time.

  3. Jon Nylander repo owner

    +2 time zones are especially tricky to get exactly right on all platforms. Fortunately the differ very little from each other.

    But Pakistan? Asia/Karachi? Are you sure? That's a +5 time zone without DST. I just cannot get that to happen in any system/browser I've tried. (IE 8-10 in windows XP,7 and 8)

  4. Matt Johnson

    Nils Kilden-Pedersen - This isn't about historical zones. Beirut and Jerusalem are actually different in modern times.

    The current distinguishing factor is their start/stop dates and times for daylight savings. Beirut transitions at midnight, while Jerusalem transitions at 2:00 AM. Beirut's DST dates for this year are 2013-03-30 to 2013-10-26, while Jerusalem's are 2013-03-29 to 2013-10-06.

    BTW - That should be a good test to distinguish them.

  5. Jon Nylander repo owner

    That is how I distinguish between them :)

    The problem is to get that distinction to work across all platforms and browsers. A Linux machine with updated IANA files is easy. A Windows machine is usually more dodgy to interpret. It all comes down to the combination of browser and machine. Each combination tends to have its pet peeves with timezones.

    Especially the wide variety of flavours of UTC+2 are tricky to detect with the same rules across machines. Other time zones are a breeze in comparison.

    I'm working on it for a 1.0.5 release. But feel free to investigate if you have the time. At the moment I am pretty cramped.


  6. Matt Johnson

    Just to update, there is variation between browsers also.

    Windows 8. Timezone set to "(UTC+02:00) Jerusalem".

    On Chrome 27, I get "Asia/Beirut"

    On IE10, I get "Asia/Damascus"

    I wonder what it is in the browser's interpretation of the time zone that is different?

  7. Jon Nylander repo owner

    Basically, for those very similar timezones in the middle eastern +2 span there is not much to do to make it perfectly granular. Since most of them differ in DST change by an hour here or there and this script is supposed to generate a timezone for backend use most of those timezones are mostly interchangeable. But yes, it bothers me too.

  8. Log in to comment