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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to