NSDateFormatter setDoesRelativeDateFormatting: broken?
NSDateFormatter setDoesRelativeDateFormatting: broken?
- Subject: NSDateFormatter setDoesRelativeDateFormatting: broken?
- From: Laurent Daudelin <email@hidden>
- Date: Fri, 08 Apr 2011 16:44:03 -0700
Is it me or is NSDateFormatter's setDoesRelativeDateFormatting: is broken?
Here is the code I use to create a new NSDateFormatter instance:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] initWithDateFormat:@"%Y-%m-%d %H:%M:%S" allowNaturalLanguage:YES];
[dateFormatter setLocale:[NSLocale currentLocale]];
[dateFormatter setDoesRelativeDateFormatting:YES];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterLongStyle];
When I use stringFromDate:, the date is always output like 4/8/11 3:50:50 PM. I was expecting that it would output something more along the line of "Today 3:50:50 PM" or something like that.
The doc gives this example for setDoesRelativeDateFormatting:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterNoStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSLocale *frLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"];
[dateFormatter setLocale:frLocale];
[dateFormatter setDoesRelativeDateFormatting:YES];
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:60*60*24*3];
NSString *dateString = [dateFormatter stringFromDate:date];
NSLog(@"dateString: %@", dateString);
// Output
// dateString: après-après-demain
So, what's wrong with this? Am I missing something or is NSDateFormatter setDoesRelativeDateFormatting is broken somehow?
-Laurent.
--
Laurent Daudelin
AIM/iChat/Skype:LaurentDaudelin http://www.nemesys-soft.com/
Logiciels Nemesys Software 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