• 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
NSDateFormatter natural language issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSDateFormatter natural language issue


  • Subject: NSDateFormatter natural language issue
  • From: Jeremy Dronfield <email@hidden>
  • Date: Mon, 12 Dec 2005 14:01:48 +0000

I'm creating a date formatter for a text field like so:

NSDateFormatter *dateFormat;
dateFormat = [[NSDateFormatter alloc] initWithDateFormat: [[NSUserDefaults standardUserDefaults] objectForKey:NSDateFormatString] allowNaturalLanguage:YES];
[newEntryField setFormatter:dateFormat];
[dateFormat release];

I'm in Britain, so I use the date format dd-mm-yyyy. However, when the text "11/12/05" is typed into the field, it gets represented as "12 November 2005" instead of "11 December 2005". So, the formatting is correct, but the interpretation of the value entered by the user is incorrect - i.e. it's interpreted according to the US date standard.

Is there a way around this? I see that Tiger has introduce a - setLocale: method. I've no idea whether this would fix the problem. Also, experiments and a trawl of the list archive suggests that it won't have any effect on a formatter created with - initWithFormat:allowsNaturalLanguage:. Can anyone advise on this?

Regards,
Jeremy
_______________________________________________
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
  • Prev by Date: Re: call an action of another class
  • Next by Date: Re: Detecting key down in application:OpenFile:
  • Previous by thread: Re: call an action of another class
  • Next by thread: NSFileManager Error List?
  • Index(es):
    • Date
    • Thread