• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: 12 hr vs 24 hr time display
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 12 hr vs 24 hr time display


  • Subject: Re: 12 hr vs 24 hr time display
  • From: Sandor Szatmari <email@hidden>
  • Date: Tue, 03 Jan 2017 14:42:34 -0500

Alex,

> On Jan 3, 2017, at 13:47, Alex Zavatone <email@hidden> wrote:
>
> iOS or Mac?
>
> In any case, this will help you out to no end.
>
> http://NSDateformatter.com/

Thanks, I'll check this out.
>
> And note that the case of the letters you use in your formatter matter.

I don't think I said case doesn't matter.  It certainly does... e.g. A vs. a, H vs. h, Y vs. y, ...  have significance.  As far as I'm aware, and according to http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns there is only one specifier for AM/PM, and that is lowercase 'a', and it is germane only to 12 hr time format strings.  'A' specifies milliseconds in day.  The only discussion of case was when I explained why I didn't need to, or rather shouldn't, consider uppercase 'AM'.  Those tokens have independent significance in a format string.  To clarify for future readers of this thread, I was not implying case doesn't matter.  Indeed, I was saying case does matter and looking for lowercase 'a' was appropriate.  Thanks for pointing that out.

Sandor

>
> GL.
> - Alex Zavatone
>
>
>> On Jan 3, 2017, at 12:16 AM, Sandor Szatmari 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
>
_______________________________________________

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


References: 
 >12 hr vs 24 hr time display (From: Sandor Szatmari <email@hidden>)
 >Re: 12 hr vs 24 hr time display (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: 12 hr vs 24 hr time display
  • Next by Date: Re: 12 hr vs 24 hr time display
  • Previous by thread: Re: 12 hr vs 24 hr time display
  • Next by thread: Finalizing CVPixelBuffer while lock count is 1
  • Index(es):
    • Date
    • Thread