David Cantrell wrote:
Tatsuhiko Miyagawa wrote:

You can get the user's country ... from Accept-Language HTTP header

No you can't. I prefer to use English (specifically en-gb) whether I'm in the UK, Germany or Japan. Even if I were to move to Japan permanently, I'd still prefer to use English, and so leave that header set to en-gb, but would also like sites to know that I'm in the Asia/Tokyo timezone.

A better method would be to find all the time zones with the same offset as the user. You can get this offset from javascript if you're using a web interface. What you don't have is a list of current offsets, so you'd have to load each and every time zone module to get its offset. Not fast and not cheap.

I'd consider
a) Get a list of time zones that are currently in use (ie, they didn't stop in 1982 .. this might be all of them, I can't remember) b) Create a hash of arrays where the key is the offset (all offsets for the TZ .. DST and non-DST)
   eg: ( 1100 => [ 'Australia/Melbourne', 'Australia/Sydney' ... ] )
c) Store that somewhere.

Now when you get an offset of 1100, you have a LOT smaller list of possible TZs. Present that list to the user. Along with a button to 'show all time zones'.

Cheers!
Rick Measham



--
Message  protected for iSite by MailGuard: e-mail anti-virus, anti-spam and 
content filtering.
http://www.mailguard.com.au


Reply via email to