Re: 12 hr vs 24 hr time display
Re: 12 hr vs 24 hr time display
- Subject: Re: 12 hr vs 24 hr time display
- From: Steve Christensen <email@hidden>
- Date: Tue, 03 Jan 2017 07:17:44 -0800
In the Date & Time preference panel, I assume that you're referring to the option on the Clock tab. If so, those settings refer only to the menubar clock display.
If you notice in that same preference panel, on the Date & Time tab, there is a message at the bottom that says, "To set date and time formats, use the Language & Region preferences." Clicking the button takes you to that other panel, and there you will find a checkbox that lets you select 24-hour time.
The Language & Region settings are what specify the locale that is used for formatting date and time values (among other things), which is why you see those changes reflected in the NSDateFormatter methods.
> On Jan 2, 2017, at 10:16 PM, Sandor Szatmari <email@hidden> wrote:
>
> I am working on a small application where the primary function is to display the time to the user. My hope was to honor the user's preference setting. I am either missing something or honoring the user's preference is harder than expected.
>
> So, there are two places to set 24 hr time display.
>
> 1. Date & Time preference panel
> 2. Language & Region preference panel
>
> The cocoa frameworks react differently depending on where you set this.
>
> If set by method 1, cocoa frameworks seem unaware of this setting and it appears this is cosmetic in that it only affects the display of the clock in the NSStatusBar.
>
> If set by method 2, cocoa frameworks reflect this and the Date & Time setting is disabled noting that the setting has been overridden.
>
> So if a user uses method 1, potentially unaware of method 2, how should one go about determining the user's intentions.
>
> There are deprecated methods using: (didn't try, it's deprecated)
> NSUserDefaults with the key NSShortTimeDateFormatString
>
> 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);
>
> Can anyone provide any clarity here?
>
> Sandor
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden