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: Ken Thomases <email@hidden>
- Date: Sat, 4 Apr 2009 07:17:16 -0500
On Apr 4, 2009, at 7:01 AM, 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.
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.
Unless I've missed something, you left out an important part. How are
you storing/serializing the date information and later "recovering" it?
Regards,
Ken
_______________________________________________
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