I'm forwarding this message from Conrad Irwin, who is not on the time zone mailing list. Those of you who are on the list, please direct replies appropriately. --ado -----Original Message----- From: Conrad Irwin [mailto:conrad.irwin@gmail.com] Sent: Monday, August 08, 2011 7:59 To: tz@lecserver.nci.nih.gov Subject: Fingerprinting timezones Hello there, Thank you for the timezone database - it is a phenomenal resource. The problem I would like to solve is that of having to ask a user of a web-app for their timezone. While there is no way to directly query for the user's timezone, the javascript engine in their web-browser is capable of telling me the offset from UTC at any date. It seems like, by selecting some number of dates to query, I should be able to gather enough information to uniquely identify any given timezone (or at least make a very good guess for a large proportion of the user-base). Before I embarked on doing this, I wanted to ask if anyone has seen a similar attempt in the past? Are there some "gotchas" that mean that this isn't actually as feasible as I naïvely hope? Conrad
From: Conrad Irwin [mailto:conrad.irwin@gmail.com] Sent: Monday, August 08, 2011 7:59
I wanted to ask if anyone has seen a similar attempt in the past?
The closest analog I know, though it's not the same problem, is GNU Emacs, which guesses the far-future rules for your time zone by probing the near future. It knows about the usual patterns of rules world-wide. (It throws in the towel with Israeli rules, though -- good luck with that!)
If someone is using a particular version of the TZ database, you can probe about 5-6 past dates to discover the zone id (of course, you can't distinguish the zones that have the same rules). We do that in browsers, where there isn't an API to get the zone. Where the browser isn't using the TZ database (eg windows), you'll just get an approximation. Mark *— Il meglio è l’inimico del bene —* On Mon, Aug 8, 2011 at 21:16, Olson, Arthur David (NIH/NCI) [E] < olsona@dc37a.nci.nih.gov> wrote:
I'm forwarding this message from Conrad Irwin, who is not on the time zone mailing list. Those of you who are on the list, please direct replies appropriately. --ado
-----Original Message----- From: Conrad Irwin [mailto:conrad.irwin@gmail.com] Sent: Monday, August 08, 2011 7:59 To: tz@lecserver.nci.nih.gov Subject: Fingerprinting timezones
Hello there,
Thank you for the timezone database - it is a phenomenal resource.
The problem I would like to solve is that of having to ask a user of a web-app for their timezone. While there is no way to directly query for the user's timezone, the javascript engine in their web-browser is capable of telling me the offset from UTC at any date.
It seems like, by selecting some number of dates to query, I should be able to gather enough information to uniquely identify any given timezone (or at least make a very good guess for a large proportion of the user-base).
Before I embarked on doing this, I wanted to ask if anyone has seen a similar attempt in the past? Are there some "gotchas" that mean that this isn't actually as feasible as I naïvely hope?
Conrad
There is a javascript library that does this reasonably well for a subset of timezones - https://bitbucket.org/pellepim/jstimezonedetect/wiki/Home. It has part of the tz database inside the javascript. This is very useful if you want to determine the timezone from the client only. As was suggested, you can also calculate UTC offsets at various dates and send these to a server to let the server calculate the time zone. --Kelly
Thank you all for your replies (including those received off-list). I'm very encouraged, and will have a go at doing this when I next find a spare weekend :). Conrad On Tue, Aug 9, 2011 at 7:05 AM, Mark Davis ☕ <mark@macchiato.com> wrote:
If someone is using a particular version of the TZ database, you can probe about 5-6 past dates to discover the zone id (of course, you can't distinguish the zones that have the same rules). We do that in browsers, where there isn't an API to get the zone.
Where the browser isn't using the TZ database (eg windows), you'll just get an approximation. Mark — Il meglio è l’inimico del bene —
On Mon, Aug 8, 2011 at 21:16, Olson, Arthur David (NIH/NCI) [E] <olsona@dc37a.nci.nih.gov> wrote:
I'm forwarding this message from Conrad Irwin, who is not on the time zone mailing list. Those of you who are on the list, please direct replies appropriately. --ado
-----Original Message----- From: Conrad Irwin [mailto:conrad.irwin@gmail.com] Sent: Monday, August 08, 2011 7:59 To: tz@lecserver.nci.nih.gov Subject: Fingerprinting timezones
Hello there,
Thank you for the timezone database - it is a phenomenal resource.
The problem I would like to solve is that of having to ask a user of a web-app for their timezone. While there is no way to directly query for the user's timezone, the javascript engine in their web-browser is capable of telling me the offset from UTC at any date.
It seems like, by selecting some number of dates to query, I should be able to gather enough information to uniquely identify any given timezone (or at least make a very good guess for a large proportion of the user-base).
Before I embarked on doing this, I wanted to ask if anyone has seen a similar attempt in the past? Are there some "gotchas" that mean that this isn't actually as feasible as I naïvely hope?
Conrad
Hi Conrad, The trick to getting TZ from Javascript is to unbundle it from DST first. As a proof of concept I wrote some code to unpack the Date class and from it make a rough estimate of geo-location. The code is in Actionscript but is commented and will work equally well for Javascript. http://www.computus.org/journal/?p=1055 best regards, John D
On 09/08/11 05:16, Olson, Arthur David (NIH/NCI) [E] wrote:
The problem I would like to solve is that of having to ask a user of a web-app for their timezone. While there is no way to directly query for the user's timezone, the javascript engine in their web-browser is capable of telling me the offset from UTC at any date.
It seems like, by selecting some number of dates to query, I should be able to gather enough information to uniquely identify any given timezone (or at least make a very good guess for a large proportion of the user-base).
Before I embarked on doing this, I wanted to ask if anyone has seen a similar attempt in the past? Are there some "gotchas" that mean that this isn't actually as feasible as I naïvely hope?
I happened to come across this today: http://site.pageloom.com/automatic-timezone-detection-with-javascript The code and an explanation is here: https://bitbucket.org/pellepim/jstimezonedetect/wiki/Home jch
On Thu, Aug 11, 2011 at 2:17 AM, John Haxby <john.haxby@oracle.com> wrote:
I happened to come across this today: http://site.pageloom.com/automatic-timezone-detection-with-javascript
The code and an explanation is here: https://bitbucket.org/pellepim/jstimezonedetect/wiki/Home
Awesome — thank you very much for sharing :). Conrad
participants (7)
-
Conrad Irwin
-
John Dalziel
-
John Haxby
-
Kelly Grizzle
-
Mark Davis ☕
-
Olson, Arthur David (NIH/NCI) [E]
-
Paul Eggert