NSDateFormatter bug in timeZone
NSDateFormatter bug in timeZone
- Subject: NSDateFormatter bug in timeZone
- From: Jon <email@hidden>
- Date: Sun, 26 Apr 2009 19:41:51 -0600
it appears there is a bug in Apple's date formatter:
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"MMM-dd-yy HH:mm:ss zzz"];
NSDate *theDate = [inputFormatter dateFromString:@"Apr-04-09
10:30:03 PDT"];
this gives the wrong timezone in "theDate"??? (unless of course you
happen to be in the PDT timezone) it looks like it ignores the
format, and just puts in current time zone. it should be -0700
at the end of the "theDate" if you look at it in a debugger, but it
is wrong for anyone that is not in the PDT...
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[inputFormatter setLocale:[[NSLocale alloc]
initWithLocaleIdentifier:@"en_US"]];
[inputFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:
0]];
[inputFormatter setDateFormat:@"MMM-dd-yy HH:mm:ss zzz"];
NSDate *theDate = [inputFormatter dateFromString:@"Apr-04-09
10:30:03 PDT"];
this gives me a NIL in "theDate" because timeZoneForSecondsFromGMT
is some how not working, or i have it wrong.....
also using the natural language formater properly gives me the correct
time Zone, but as soon as you store it in a Data Source, it comes
back out with the current time zone, and the time adjusted so that it
is correct time at least... but this shouldn't happen? should it.
Jon.
_______________________________________________
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