06th Apr 2007
Report-an-Apple-Bug Friday! 1
My first! I’m so excited.
Title: NSCalendarDate’s descriptionWithCalendarFormat method doesn’t work properly
Product: Mac OS X
Version: 10.4.9
Classification: Other Bug
Is it Reproducible?: Always
Summary:
When using NSCalendarDate’s descriptionWithCalendarFormat method, incorrect values are returned.
Steps to Reproduce:
1. Create a Cocoa app. Use the following code it in:
NSCalendarDate *time = [NSCalendarDate calendarDate];
NSString *timeOfDay = [time descriptionWithCalendarFormat:@”%X”];
NSString *dayName = [time descriptionWithCalendarFormat:@”%A”];
NSLog(@”Today is %@, and the time is %@.”, dayName, timeOfDay”);
Expected Results:
The app should print “Today is Friday, and the time is 11:02 PM.” (Assuming it actually is Friday at 11:02PM, and those your time formats are the same.)
Actual Results:
The app prints “Today is Friday, and the time is 23:02:23 Canada/Eastern.”, which is not how the time should look according to the documentation for %X. If you use descriptionWithCalendarFormat:@”%X” locale:[[NSUserDefaults standardUserDefaults] dictionaryRepresentation], the output is not much better: “Today is Friday, and the time is Friday, April 6, 2007 11:08:51 PM Canada/Eastern”.
The dates and times programming guide states that %X should return “time using the time representation for the locale”. This is obviously not happening.
Regression:
Always occurs. Other regressions unknown.
Notes:
No Known work arounds, other than specifying the time format explicitly (@”%1I:%M %p”) which is ugly and doesn’t take into account localized formats.
Leave a Reply