• 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: Cocoa-dev Digest, Vol 11, Issue 267
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa-dev Digest, Vol 11, Issue 267


  • Subject: Re: Cocoa-dev Digest, Vol 11, Issue 267
  • From: Jim McGowan <email@hidden>
  • Date: Wed, 14 May 2014 22:23:36 +0800

On 14 May, 2014, at 10:08:39 pm HKT, Jens Alfke <email@hidden>
>
> On May 14, 2014, at 6:41 AM, Jonathan Mitchell <email@hidden> wrote:
>
>> Is there a way to obtain an NSDate object from a casually entered user string, say: 1 1 2015 or 25 jul 15?
>
> There’s no easy way. You can create a whole bunch of format strings for every exact format you expect, and then try to parse the input using each one in turn (tip: the order you test the formats in is important); or you can write a custom parser (hopefully using a parser generator like ANTLR.) Or you could search around to see if there are any open-source libraries that do this … I just checked the About box of Fantastical (which has a really good date parser) but didn’t see anything relevant. Good luck!
>
> —Jens

There is NSDate +dateWithNaturalLanguageString:, but milage may vary, as the docs say:

“It may give unexpected results, and its use is strongly discouraged”

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html#//apple_ref/occ/clm/NSDate/dateWithNaturalLanguageString:

Jim
_______________________________________________

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


  • Prev by Date: Re: Share and store RSA - public key in java server and vice versa
  • Next by Date: Re: Share and store RSA - public key in java server and vice versa
  • Previous by thread: Re: Obtain an NSDate object from any casually entered user string
  • Next by thread: ARC clean up?
  • Index(es):
    • Date
    • Thread