• 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: Need localization-proof method of transporting dates.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need localization-proof method of transporting dates.


  • Subject: Re: Need localization-proof method of transporting dates.
  • From: Marcel Weiher <email@hidden>
  • Date: Sat, 4 Apr 2009 13:36:12 -0700


On Apr 4, 2009, at 5:01 , Graham Cox wrote:

One problem I've had occasional reports of is that the expiry is prematurely detected, and it seems to be on systems with system language set other than English. I need to store and check the dates in a way that is not sensitive to this. I thought I was, yet the reports persist.

Dates are tricky. One issue is that what's consistent in a machine sense is often at odds with consistent from the user's point of view, and that various layers of interpretation get you a bit of a muddle (classic case is calendar programs treating dates as absolute times, so when you schedule appointments in a different time-zone for a trip and then switch to that time-zone during the trip, all your appointments shift).


The muddle problem can be largely eliminated by storing a fairly unambiguous value, such as seconds since 1970 (or 2000 see NSTimeInterval), preferably as a 64 bit value (NSTimeInterval's double should also work for most applications..).

Once you've left the muddle behind, you are left with interpretations. What time-zone is the value interpreted in? GMT? The user's time-zone? When are offsets applied?

If you are archiving the date, my guess is that it is being archived with your local time-zone, and then compared to a date that is in your client's time-zone.

The solution I have is to store the date year/month/day, completely independent of NSDate. I then construct the expiry NSDate locally, so it will be interpreted in the same context as the current date that "[NSDate date]" delivers.

I also tend to not say when exactly the software expires... :-)

Hope that helps,

Marcel

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Need localization-proof method of transporting dates. (From: Graham Cox <email@hidden>)

  • Prev by Date: Using bindings to set NSImageView from filename
  • Next by Date: Re: Reading cab into object
  • Previous by thread: Re: Need localization-proof method of transporting dates.
  • Next by thread: Re: Need localization-proof method of transporting dates.
  • Index(es):
    • Date
    • Thread