On Jan 2, 2017, at 22:16 , Sandor Szatmari <[email protected]> wrote:
> 
> There are supported methods using: (works with method 2)
>    NSString *format = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 
> locale:[NSLocale currentLocale]];
>    BOOL is24Hour = ([format rangeOfString:@"a"].location == NSNotFound);

Well of course this won’t work in every locale, not even all the 
English-speaking ones, since (IIRC) it’s “AM” in some of them, but I assume 
you’ve breezed right past that small point. :)

It seems to me you have two choices. One is to honor the setting for time 
*text* and to use the date formatter result unmodified (which means you might 
get more characters than just the 3 or 4 or 5 that represent the time with a 
possible separator). Or, if your app really is more like a clock, then I’d make 
the 12/24 hr format a setting within the app. As you’ve seen from the menu bar 
clock, there does seem to be a possible distinction between clock time format 
and annotation time. Since you can’t access the menu bar format (no public API 
at least), a one-time app setting seems reasonable.

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to