Re: Need localization-proof method of transporting dates.
Re: Need localization-proof method of transporting dates.
- Subject: Re: Need localization-proof method of transporting dates.
- From: Tommy Nordgren <email@hidden>
- Date: Sat, 4 Apr 2009 21:57:31 +0200
On Apr 4, 2009, at 2:01 PM, Graham Cox wrote:
My app encodes expiry dates for demo versions, etc.
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.
Here's what I'm doing:
The stored date originally comes from a NSDatePicker control,
textual with stepper. I retrieve the date using its -dateValue method.
The date, along with other data, is digitally signed with a SHA-1
hash, which in turn is based on the object's -hash method. As far as
I could tell, the -hash method returns a value that is sensitive to
the actual stored date, but not to the date localization on the
system.
At runtime, the date is recovered and verified by rehashing and
comparing the hash, then the date value is simply compared to see if
the current date is before or after it using [[NSDate date]
timeIntervalSinceDate:expiryDate] (if negative, hasn't expired).
Can anyone spot any problem with this approach? Note that the SHA-1
check appears to pass OK - it's the date comparison that seems to be
wrong. Unfortunately I can't reproduce the bug locally so I'm
relying on reports from relatively non-technical testers who aren't
able to give me much to go on.
--Graham
I suggest encoding your dates as strings, in standard Iso Text Format
(yyyy-mm-ss)
-----------------------------------
See the amazing new SF reel: Invasion of the man eating cucumbers from
outer space.
On congratulations for a fantastic parody, the producer replies :
"What parody?"
Tommy Nordgren
email@hidden
_______________________________________________
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