Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
NSDateFormatter bug in timeZone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDateFormatter bug in timeZone



 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




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.