• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: storing NSTimestamp values as GMT, displaying as (client) local?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >storing NSTimestamp values as GMT, displaying as (client) local? (From: Leif Harrison <email@hidden>)
 >Re: storing NSTimestamp values as GMT, displaying as (client) local? (From: Andrew Lindesay <email@hidden>)
 >Re: storing NSTimestamp values as GMT, displaying as (client) local? (From: Travis Britt <email@hidden>)

  • Prev by Date: Re: Frontbase Database access on Deploy
  • Next by Date: JavaClient offline storage / replication
  • Previous by thread: Re: storing NSTimestamp values as GMT, displaying as (client) local?
  • Next by thread: NSTimestampFormatter adjusts TZ for display, SimpleDateFormat doesn't?
  • Index(es):
    • Date
    • Thread