Note: groups.io will be down for maintenance on Monday, September 26th, starting at 9AM Pacific Time (4PM Monday September 26, 2022 UTC), for approximately one hour.
Determine System Time Format (12hr vs 24hr)
I have been using the following code to determine if a system is set to 12hr or 24hr time for sometime…
NSString *formatStringForHours = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale currentLocale]];
NSRange containsH = [formatStringForHours rangeOfString:@"H"];
BOOL shouldUse24HrTime = containsH.location != NSNotFound;
format = (shouldUse24HrTime) ? @"H:mm" : @"h:mm";
Now, on Catalina, I am realizing that this code is failing. Unfortunately, I don't know when this started to fail.
It always returns 'h a', whereas previously it returned 'H'.
Is anyone else seeing the same thing? If others can confirm this same apparently errant behaviour I'll file a bug report. First, I want to be sure it's not just my system…
Also, does anyone know an alternative, or better, way to determine the time format of the system? ('Use 24-hour clock' as found in Date & Time System Preferences)