On iPadOS 13, when the user sets "24-hour time" to FALSE, the following code would produce the following output:
Code:
+ (NSString *)dateStringFromDate:(NSDate *)date {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
return [dateFormatter stringFromDate:date];
}
Output:
2020-10-19T11:55:29Z
But, on iPadOS 14, the same code produces this output:
2020-10-19T12:38:06 p.m.Z
Note: the 24-hour time toggle was set to FALSE on both operating systems. For some reason, iPadOS 14 seems to be respecting the AM/PM setting in the NSDateFormatter, but iPadOS 13 was not.
I know that setting the locale to this will remove the AM/PM entirely:
dateFormatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
But, we are trying to understand why the problem only occurs on iPadOS 14 and not 13 when the iPad settings are exactly the same.
Foundation's date and time APIs are built on top of a version of ICU that ships with Apple platforms. Between OS releases, both Foundation and ICU code receive updates, which fix old bugs, and occasionally introduce new bugs. At whatever API layer the change here has manifested (and whether this is considered a bug at that layer), you're seeing the consequence of code having changed.
The behavior here does not look right, but luckily, a locale of en_US_POSIX
(which you should likely be setting anyway) resolves the issue.