• 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: Thoroughly confused on date formatting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Thoroughly confused on date formatting


  • Subject: Re: Thoroughly confused on date formatting
  • From: Deborah Goldsmith <email@hidden>
  • Date: Fri, 29 Sep 2006 13:15:14 -0700

On Sep 29, 2006, at 10:36 AM, Matt Neuburg wrote:
Here is what I do:

NSDateFormatter *dateFormatter =
   [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateStyle:NSDateFormatterShortStyle];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
NSMutableString* f =
   [NSMutableString stringWithString:[dateFormatter dateFormat]];

Aha, so now I have the user's preferences expressed as a mutable string in
ICU format. So now I mutate the string to combine the user's preferences
with my own (e.g. get rid of everything but hours and minutes, in your
case), and then:


[dateFormatter setDateFormat:f];

This can work, but not all the time. It isn't really possible to determine which constant strings go with which fields. If you get rid of the seconds, you also need to get rid of the string. Everyone is familiar with this case:


hh:mm:ss

but how about this one?

hh時mm分ss秒

In the first case, you get rid of the colon between mm and ss. In the second case, you get rid of the trailing character *after* ss.

This is a known problem, and is being worked on in ICU. See the description of "availableFormats" in:

http://www.unicode.org/reports/tr35/#Calendar_Elements

Deborah Goldsmith
Internationalization, Unicode liaison
Apple Computer, Inc.
email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: Thoroughly confused on date formatting (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: NSAnimation to trigger live resize
  • Next by Date: Re: Strange issue with NSSplitView and NSTableView (bug ?)
  • Previous by thread: Re: Thoroughly confused on date formatting
  • Next by thread: Conversion of =E? string
  • Index(es):
    • Date
    • Thread