I'm having an issue with obtaining the full name for the day of week in iOS 6 NSDate object (in iOS 7 works fine). I've searched stackoverflow for similar issues but I didn't find what I was looking for.
My test case is:
formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"EEEE"];
[formatter setDoesRelativeDateFormatting:NO];
NSDate *testDate = [NSDate dateWithTimeIntervalSince1970:1384551041.389218];
NSLog(@"%@",[formatter stringFromDate:testDate]);
The expected output is Friday
(localized to your device region format and on a gregorian calendar), it works on iOS 7 but on iOS 6 it returns an empty description. I've tested in actual devices with the same region format set.
As far as I know, iOS 6 uses tr35-25 formatting according to this documentation, and the EEEE
specifies full name day of week in that format.
Am I missing something?
That actually looks like a bug in NSDateFormatter
on iOS 6. However, it seems that
the bug occurs only if you explicitly set
[formatter setDoesRelativeDateFormatting:NO];
If you omit that line (and NO
is the default anyway) then the result is OK (at least when I tested it).
Remark: I assume that setDoesRelativeDateFormatting
is only meant to be used in connection
with setDateStyle:
, but that is pure guessing.
If you remove [formatter setDoesRelativeDateFormatting:NO]; from your code then you will get the result in both iOS 6.0 and iOS 7.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With