You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Christopher Schultz <ch...@christopherschultz.net> on 2011/12/21 17:43:59 UTC

[OT] Displaying Time Zones for user preferences

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

We're getting to the point in our project where allowing users to
identify their own time zone so we can display adjusted timestamps is
something we can no longer do without. I'm trying to figure out how to
display a list of time zones in a drop-down list for users to pick.

Java's TimeZone class provides a static method, getAvailableIDs, that
returns the huge list of time zones that the current JVM knows about.
Then, I can use this list to fetch each TimeZone object by id and
shove them into a list to display on the screen. So far, so good.

To display, I have two options: use the "ID" which is usually of the
form "America/New_York" or use the "display name" which varies wildly
from zone to zone.

Here's an example of a few time zones that get returned from my JVM
(Oracle Java 1.6.0_26-b03 on a Debian Squeeze system):

ID                 Display Name (English)
ACT                Central Standard Time (Northern Territory)
AET                Eastern Standard Time (New South Wales)
AGT                Argentine Time
ART                Eastern European Time
AST                Alaska Standard Time
Africa/Abidjan     Greenwich Mean Time
Africa/Accra       Ghana Mean Time
...
America/Chicago    Central Standard Time
...
CST                Central Standard Time
...

Already, I can see a few problems:

1. Time zones are repeated with different IDs. That might not be such
   a big deal, since some people might like to look for "CST" and others
   might be looking for "America/Chicago". But including both requires
   the list to be very long.

2. If I go with "display name" instead of "id", then I have to decide
   which id to use when there are many choices. For instance,
   "Greenwich Mean Time" gets used a lot, but has lots of ids. If
   I arbitrarily choose "Africa/Abidjan" as the id to use for that
   label, then everyone who expected GMT might suddenly find their
   timestamps off if the Abidjanese people decide in the future
   to abandon GMT.

3. You can't see it, but the "ids" are not localized. The "display name"
   is available for many languages directly from the JVM but not the
   id. That means that the nice labels like "America/Chicago" will
   always have those labels, regardless of the user's display language.
   Not ideal.

4. We (the US) are currently not in DST, so "CST" is displayed
   and not "CDT". I checked, and it looks like there is no
   "CDT" time zone so during DST it will still say "CST" which
   probably nobody but me will notice.

I feel like I've got a Catch-22, here: despite the wealth of
information provided by the JVM, I think I might still have to just
have a giant list of supported time zones and hand-localize them,
especially if I want to have "America/New York"-style labels.

Does anyone have any suggestions?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7yDM8ACgkQ9CaO5/Lv0PBwdwCfbI1xwryuMOWpP+pf+CAGtmTZ
vIQAn2IyFrAz17a45C9Yr0L+jTzCenn7
=I5AZ
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Displaying Time Zones for user preferences

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/12/21 Christopher Schultz <ch...@christopherschultz.net>:
>
> We're getting to the point in our project where allowing users to
> identify their own time zone so we can display adjusted timestamps is
> something we can no longer do without. I'm trying to figure out how to
> display a list of time zones in a drop-down list for users to pick.
>
> Java's TimeZone class provides a static method, getAvailableIDs, that
> returns the huge list of time zones that the current JVM knows about.
> Then, I can use this list to fetch each TimeZone object by id and
> shove them into a list to display on the screen. So far, so good.
>
> To display, I have two options: use the "ID" which is usually of the
> form "America/New_York" or use the "display name" which varies wildly
> from zone to zone.
>
> Here's an example of a few time zones that get returned from my JVM
> (Oracle Java 1.6.0_26-b03 on a Debian Squeeze system):
>
> ID                 Display Name (English)
> ACT                Central Standard Time (Northern Territory)
> AET                Eastern Standard Time (New South Wales)
> AGT                Argentine Time
> ART                Eastern European Time
> AST                Alaska Standard Time
> Africa/Abidjan     Greenwich Mean Time
> Africa/Accra       Ghana Mean Time
> ...
> America/Chicago    Central Standard Time
> ...
> CST                Central Standard Time
> ...
>
> Already, I can see a few problems:
>
> 1. Time zones are repeated with different IDs. That might not be such
>   a big deal, since some people might like to look for "CST" and others
>   might be looking for "America/Chicago". But including both requires
>   the list to be very long.
>
> 2. If I go with "display name" instead of "id", then I have to decide
>   which id to use when there are many choices. For instance,
>   "Greenwich Mean Time" gets used a lot, but has lots of ids. If
>   I arbitrarily choose "Africa/Abidjan" as the id to use for that
>   label, then everyone who expected GMT might suddenly find their
>   timestamps off if the Abidjanese people decide in the future
>   to abandon GMT.
>
> 3. You can't see it, but the "ids" are not localized. The "display name"
>   is available for many languages directly from the JVM but not the
>   id. That means that the nice labels like "America/Chicago" will
>   always have those labels, regardless of the user's display language.
>   Not ideal.
>
> 4. We (the US) are currently not in DST, so "CST" is displayed
>   and not "CDT". I checked, and it looks like there is no
>   "CDT" time zone so during DST it will still say "CST" which
>   probably nobody but me will notice.
>
> I feel like I've got a Catch-22, here: despite the wealth of
> information provided by the JVM, I think I might still have to just
> have a giant list of supported time zones and hand-localize them,
> especially if I want to have "America/New York"-style labels.
>
> Does anyone have any suggestions?
>

IIRC when I installed Fedora on my VM recently it displayed a zoomable
map of Earth surface, allowing me to select the town where I live (and
thus the time zone).

I think you cannot omit entries from the list. You can do some dynamic
filtering based on country or continent (that user types in).

The time zone selection is tricky because you select not only current
time shift value, but all previous time shift rules for this
territory.  So if small city was in Area A but in year xx it was
administratively moved to Area B with different time shift rules,  it
makes this small city a separate time zone with its own historical
record. (Maybe I am wrong, but that is what I think it is).

If your application is only concerned with the current time then your
timezone selection might be a bit more simple than that.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Displaying Time Zones for user preferences

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 12/21/11 2:24 PM, André Warnier wrote:
> Can you not use GeoIP to find out where a user is connecting from,
> and select his time zone automatically for him/her ? (Saves your
> conumdrum about how to display the choices)
> 
> http://www.geoip.co.uk/ Looks pretty accurate for me :
> 
> IP Address: 84.158.10.215 Country: Germany Country code: DE Region:
> 01 Longitude: 48.4667 Latitude: 8.9333

So, now I get to try to figure out how to map your lat/long into a
Time Zone?

Also, your preferred time zone isn't always where you actually are.

- -chris

> Status: Clear Threat Level: 0
> 
> I have not looked further, but I would not be utterly surprised if
> there existed already some Java servlet filter or so to get the
> client's timezone automatically, and stuff it into some value which
> you can grab.

I Googled-around a bit and didn't find much.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7zp/gACgkQ9CaO5/Lv0PDDywCfamupPY93UwlDNkZGm5nOWqA/
aFoAoKfG+29twl6mWSW71jrrbNHHMGJm
=5PcB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Displaying Time Zones for user preferences

Posted by Hassan Schroeder <ha...@gmail.com>.
On Wed, Dec 21, 2011 at 11:24 AM, André Warnier <aw...@ice-sa.com> wrote:

> Can you not use GeoIP to find out where a user is connecting from, and
> select his time zone automatically for him/her ?

You still need to offer a manual selection option, because it's just not
always accurate.

Once I was investigating geo-location services while on the road to
a show (my wife driving, me working using a Verizon MiFi hotspot).

At one point I was identified by (I think) GeoIP as being somewhere
in New Jersey, while actually in the middle of Utah on US80 -- that's
2 time zones away  :-)

Speaking to the original problem: I agree that for user-friendliness,
you might have to bite the bullet and hand-tailor the dropdown list;
however, to minimize the size *as displayed*, could you include a
JavaScript routine to examine the client time and restrict the list to
the subset that would match that time?

There's only so many TZs where it's currently e.g. 12:17pm  :-)

Just a thought.
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Displaying Time Zones for user preferences

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

André,

On 12/22/11 3:51 PM, André Warnier wrote:
> As Konstantin points out separately, if you are going to use the
> local timezone for anything "serious", then you could get yourself
> into a lot of complications.

No, he's just saying "once a timezone, always a timezone".

> And who says the users are going to go though the trouble of
> selecting the right zone anyway?

Mine are. We have had complaints that all our timestamps are in "New
York" time. Actually, the real complaint was that we were displaying
timestamps without a time zone /at all/ and we had to tell them that
everything was in America/New_York.

Since I had to do a crapload of work just to get "EST" or "EDT"
displayed after our timestamps (because we convert from java.util.Date
- -> xs:dateTime -> on-screen format... it's a horrible mess of
poorly-compatible APIs, etc.), I figured I may as well make it
user-selectable. Now that it's user-selectable, we may as well allow
the user to, well, select it. :)

> and what if the user indeed spends his time traveling and making
> the life of the site designer difficult, like you above ? And what
> about users who are connecting first to their corporation's VPN
> from wherever they are, and of which all subsequent accesses appear
> to come from that corporation's firewall.

They can set their time zone to anything they want. And they can
change it. Or they can leave everything set to the default
(America/New_York).

> Oh wait, that was an argument against using GeoIP, wasn't it ?

:)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7zqXsACgkQ9CaO5/Lv0PAn7wCgn9Iug0qZbqsJUdc0UUp507xL
pyIAn3s0y+KaCTE1Hlefj8ox/rvTsPWe
=Ofqv
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [OT] Displaying Time Zones for user preferences

Posted by André Warnier <aw...@ice-sa.com>.
Caldarale, Charles R wrote:
>> From: André Warnier [mailto:aw@ice-sa.com] 
>> Subject: Re: [OT] Displaying Time Zones for user preferences
> 
>> Can you not use GeoIP to find out where a user is connecting 
>> from, and select his time zone automatically for him/her ?
> 
> Not reliably.  For example, it says my desktop PC is in Pennsylvania, when it's really in Minnesota (but then I'm actually in Ontario right now :-).  What you'll really get back is the registered location of the ISP or company, not necessarily that of the actual client.
> 
Well, in my case, when I am in Germany my ISP is a big nation-wide one (the one which AT&T 
was just forbidden to marry the daughter of), but the location I provided earlier was 
pretty accurate (say within 10 Km or so, good enough for a MIRV ICBM anyway).
(What I mean to say is that it is obviously much finer than the location of the ISP's 
headquarters, which in this case are 500 Km away).

I guess it depends really on what the actual purpose is in this case.  If it is just to 
make the website look more friendly, it may be good enough and avoid a lot of extra work 
and complications.  As Konstantin points out separately, if you are going to use the local 
timezone for anything "serious", then you could get yourself into a lot of complications. 
  And who says the users are going to go though the trouble of selecting the right zone 
anyway ? and what if the user indeed spends his time traveling and making the life of the 
site designer difficult, like you above ? And what about users who are connecting first to 
their corporation's VPN from wherever they are, and of which all subsequent accesses 
appear to come from that corporation's firewall. Oh wait, that was an argument against 
using GeoIP, wasn't it ?



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: [OT] Displaying Time Zones for user preferences

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com] 
> Subject: Re: [OT] Displaying Time Zones for user preferences

> Can you not use GeoIP to find out where a user is connecting 
> from, and select his time zone automatically for him/her ?

Not reliably.  For example, it says my desktop PC is in Pennsylvania, when it's really in Minnesota (but then I'm actually in Ontario right now :-).  What you'll really get back is the registered location of the ISP or company, not necessarily that of the actual client.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


Re: [OT] Displaying Time Zones for user preferences

Posted by André Warnier <aw...@ice-sa.com>.
Christopher Schultz wrote:
...>
> I feel like I've got a Catch-22, here: despite the wealth of
> information provided by the JVM, I think I might still have to just
> have a giant list of supported time zones and hand-localize them,
> especially if I want to have "America/New York"-style labels.
> 
> Does anyone have any suggestions?
> 
Can you not use GeoIP to find out where a user is connecting from, and select his time 
zone automatically for him/her ?
(Saves your conumdrum about how to display the choices)

http://www.geoip.co.uk/
Looks pretty accurate for me :

IP Address: 84.158.10.215
Country: Germany
Country code: DE
Region: 01
Longitude: 48.4667
Latitude: 8.9333
Status: Clear
Threat Level: 0

I have not looked further, but I would not be utterly surprised if there existed already 
some Java servlet filter or so to get the client's timezone automatically, and stuff it 
into some value which you can grab.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org