Re: storing NSTimestamp values as GMT, displaying as (client) local?
Re: storing NSTimestamp values as GMT, displaying as (client) local?
- Subject: Re: storing NSTimestamp values as GMT, displaying as (client) local?
- From: Ken Anderson <email@hidden>
- Date: Wed, 15 Apr 2009 10:33:28 -0400
I was going to write pretty much what Travis wrote, so I'll just say
me too
In app and DB representations should always be GMT - displays to the
user should be formatted for their local time zone.
Ken
On Apr 14, 2009, at 9:51 PM, Travis Britt wrote:
On Apr 14, 2009, at 9:04 PM, Andrew Lindesay wrote:
I'm not sure what that value is used for in the EOModel -- anybody
know?
I think Mike and I looked into this several months ago and turns out
it isn't actually used, tho it is documented in EOAttribute as being
implemented in EOAdaptorChannel. IIRC it exists in EntityModeler b/c
it was in EOModeler.
On Apr 14, 2009, at 8:46 PM, Leif Harrison wrote:
3. How can I get the local timezone (of the browser client) so that
I can use it for my WOTextfield formatters (to display local time)?
The time zone in your app and database server should be the same. I
recommend setting it explicitly in the app. (Don't rely on using the
runtime's default since this changes based on the server's time
zone.) Just use GMT! But I believe this should all work so long as
everything is operating with the same time zone. (For example, if
you have legacy data stored with a time zone region like America/New
York it's not easy to convert it accurately to GMT due to changes in
DST.) You do not want dates stored in the DB with different time
zones.
Wen a user logs in to the app you can snag their browser's gmt
offset by using javascript to write out a hidden form field
something like this:
<script>
document.write('<input type="hidden" name="gmtOffsetMinutes"
value="' + new Date().getTimezoneOffset() + '" />');
</script>
Then your login method can grab that as an integer, create a
TimeZone object from it and stash it somewhere handy (like Session.)
I create a TimeZone object from the gmt offset using
TimeZone.getTimeZone(String) with a string created by prepending
"GMT-" or "GMT+" to the offset value in hours. (Note that the
Javascript will give it to you in minutes.)
Then you can use the TimeZone obj in your formatter to display the
date in the user's time zone. Works great.
tb
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden