• 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
NSCalendarDate bug, or my fault?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSCalendarDate bug, or my fault?


  • Subject: NSCalendarDate bug, or my fault?
  • From: Dan Wood <email@hidden>
  • Date: Sat, 23 Mar 2002 17:11:44 -0800

I'm trying to format a time in an NSCalendarDate to include the
user's AM/PM designator if the user's preferences indicate a
12-hour clock, but without that if they use a 24-hour clock.

So first, I can get the time format string like this:

NSString *timeFormat = [defaults objectForKey:@"NSTimeFormatString"];

For US 12-hour format, this is "%1I:%M:%S". OK, but %p is the
designator for AM/PM, so I have to append that to my time format
string. I assume it will use the value in the NSAMPMDesignation
default, which for US is (" AM", " PM"). Note the spaces in
front of the AM and the PM.

So if my time format string is "%1I:%M%p", I would expect it to
come out with a space before the AM or PM. But it doesn't.

If I use a 24-hour clock, like Spanish, the NSTimeFormatString
is "%H:%M:%S" and the NSAMPMDesignation is ("", ""). So
everything should just work.

But instead, the AM/PM appears after my 24-hour time, e.g.
"17:01PM". This is bad.

So it appears that the %p formatter isn't hooked up to the
NSAMPMDesignation. I have to write code to scan the
NSTimeFormatString, and if it's 12-hour format, then append the
%p to my time formatter string.

Am I missing something here, or should I file a bug report?

Dan
--
Dan Wood
Karelia Software, LLC
email@hidden
http://www.karelia.com/
Watson for Mac OS X: http://www.karelia.com/watson/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSCalendarDate bug, or my fault?
      • From: Jonathan Feinberg <email@hidden>
  • Prev by Date: Beginner Questions
  • Next by Date: Cocoa advocacy and Apple... CSDF/MSDA/CMSDA
  • Previous by thread: Beginner Questions
  • Next by thread: Re: NSCalendarDate bug, or my fault?
  • Index(es):
    • Date
    • Thread