Re: [NSDate +dateWithNaturalLanguageString] question
Re: [NSDate +dateWithNaturalLanguageString] question
- Subject: Re: [NSDate +dateWithNaturalLanguageString] question
- From: Keith Duncan <email@hidden>
- Date: Sun, 13 Jul 2008 17:05:00 +0100
I worked it out using NSCalendarDate [...]
From the docs:
Important: Use of NSCalendarDate strongly discouraged. It is not
deprecated yet, however it may be in the next major OS release after
Mac OS X v10.5. For calendrical calculations, you should use
suitable combinations of NSCalendar, NSDate, and NSDateComponents,
as described in Calendars inDates and Times Programming Topics for
Cocoa.
The problem is that NSCalendarDate uses the gregorian calendar
exclusively. It's simple enough to do what you want using NSCalendar,
NSDateComponents and NSDate.
Code typed in Mail:
NSDateComponents *components = [[NSDateComponents alloc] init];
[components setMonth:4];
NSDate *now = [NSDate date];
NSDate *later = [[NSCalendar currentCalendar]
dateByAddingComponents:components toDate:now options:0];
Keith Duncan
email@hidden, 33software.com
_______________________________________________
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