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: "Gary L. Wade" <email@hidden>
- Date: Tue, 03 Jan 2017 11:52:54 -0800
Is there a problem with using +[NSDateFormatter localizedStringFromDate:dateStyle:timeStyle:]? Depending on your needs, you might also consider +[NSCalendar autoupdatingCurrentCalendar].
A user typically “sets” their region settings when they set up their Mac, and the choice of 12/24 hour display defaults to what the selected region uses. Few people change things after that, although I am, preferring a four-digit year vs two-digit for the short date format.
--
Gary L. Wade
http://www.garywade.com/ <http://www.garywade.com/>
> On Jan 3, 2017, at 8:34 AM, Sandor Szatmari <email@hidden> wrote:
>
> Jeremy,
>
>> On Jan 3, 2017, at 10:30, Jeremy Pereira <email@hidden> wrote:
>>
>>
>>> On 3 Jan 2017, at 06:16, 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.
>>
>> It seems obvious to me that method 1 only refers to the clock display in the menu bar and nothing else. It’s a sub setting of
>> “Show date and time in the menu bar”.
>>
>> If you honour whatever preference is set by method 2 as your code fragment below does, you’ll be fine.
>>
> I feel like fewer people use/find method 2, simply stopping at method 1. This may be a gross assumption on my part. Under my assumption they would simply think my app doesn't display 24 hr time or respect the system setting. Am I being to sensitive here?
>
> Sandor
>>
>>>
>>> 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
>>
>> --
>> Jeremy Pereira
>> email@hidden
>> 07884 265457
_______________________________________________
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