Just sharing what I'm doing...

It looks like getting the GMT offset and using that to create a time zone does 
not give me an object that knows about daylight savings.

So I created a different approach which I've tested in Safari/Chrome/FireFox.  
The JavaScript is like this:

<wo:hidden value="$clientTimeZoneID" id="clientTimeZoneID"/>

<script>
$('clientTimeZoneID').value = new 
Date().toString().match(/\50\w+\51/)[0].match(/\w+/);
</script>

This JavaScript gets you the ID of the timezone that appears in parenthesis 
when converting a Date object to a string.  This returns something like "EST", 
or "MST", or "PST", or "CST".  

Then from Java I can create a time zone object using the ID:

        TimeZone clientTimeZone = TimeZone.getTimeZone(clientTimeZoneID);

Using the ID is deprecated because CST could be confused with China Standard 
Time (instead of Central Standard Time).  But I guess that's okay for us 
because our clients are all US-based.  :-)

The TimeZone object created using this ID knows about daylight savings and 
makes it useful for date/time input in the client time zone.  And I can then 
know exactly what the equivalent is in my app's time zone.

P.S. I still have to test in Internet Explorer.


 
On Nov 12, 2010, at 12:37 AM, Travis Britt wrote:

> Yeah I do this by using javascript get the GMT offset reported by the browser 
> on login, and store that in the session. Then use the offset to create a 
> java.util.TimeZone and use that in a formatter to display all your time 
> stamps in the user's expected time zone.
> 
> tb
> 
> On Nov 11, 2010, at 2:30 PM, Ricardo J. Parada wrote:
> 
>> Thanks... That should get me going.
>> 
>> 
>> 
>> On Nov 11, 2010, at 4:43 PM, Johann Werner wrote:
>> 
>>> Hi Ricardo,
>>> 
>>> have a look at 
>>> http://josephscott.org/archives/2009/08/detecting-client-side-time-zone-offset-via-javascript/
>>> So you could put the presented script snippet in your login form and 
>>> extract the GMT offset of the client from the request form values.
>>> 
>>> jw
>>> 
>>> Am 11.11.2010 um 22:25 schrieb Ricardo J. Parada:
>>> 
>>>> 
>>>> What are you all doing to find out the timezone from the browser?  I'm 
>>>> guessing there is a header in the request containing this info.  
>>>> 
>>>> Thanks,
>>>> Ricardo
>>> 
>>> 
>> 
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/webobjects-dev/tbritt%40phigment.org
>> 
>> This email sent to [email protected]
> 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to