• 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: [NSDate +dateWithNaturalLanguageString] question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: [NSDate +dateWithNaturalLanguageString] question
      • From: Phil <email@hidden>
References: 
 >[NSDate +dateWithNaturalLanguageString] question (From: Jamie Phelps <email@hidden>)
 >Re: [NSDate +dateWithNaturalLanguageString] question (From: Jamie Phelps <email@hidden>)

  • Prev by Date: Re: [NSDate +dateWithNaturalLanguageString] question
  • Next by Date: Re: garbage collection and NSConnection
  • Previous by thread: Re: [NSDate +dateWithNaturalLanguageString] question
  • Next by thread: Re: [NSDate +dateWithNaturalLanguageString] question
  • Index(es):
    • Date
    • Thread