Is there a way to convert a natural language date NSString to an NSDate

Say I have the NSString @"tomorrow"

Is there any library that takes strings such as this and converts them into NSDates? I'm imagining/hoping for something like this:

NSString* humanDate = @"tomorrow at 4:15";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"x at HH:MM"];
NSDate* date = [dateFormatter dateFromString:humanDate];

I would also want to do things like "Next monday", etc. but it doesn't have to be super sophisticated. I can enforce rules on input, but I'd like a little bit of natural language available.

My alternative is to take the string, break it up into pieces, and format it manually. But I was hoping someone has already done this.

8
задан Joel 4 May 2011 в 04:32
поделиться