Skip navigation.
 
mlRe: Finding a relative date
FROM : Nir Soffer
DATE : Mon Feb 25 20:39:07 2008

On Feb 25, 2008, at 21:27, Randall Meadows wrote:

> Given a specific NSDate, I need to be able to find, say, the Sunday 
> before that date, or the Saturday after that date.  I was hoping to 
> be able to use +dateWithNaturalLanguage with something like "Sunday 
> before [myDate description]", but that just returns myDate.
>
> I know I can brute-force it, by figuring out the myDate's day, then 
> walking backward and/or forward, but is there an easier way?  One 
> more tried and true, less error-prone, that's calendar-savvy (not 
> that I'm going to need to go as far back as Oct 1582...)?


Check NSCalendarDate -dayOfWeek and -
dateByAddingYears:months:days:hours:minutes:seconds:

Best Regards,

Nir Soffer

Related mailsAuthorDate
mlFinding a relative date Randall Meadows Feb 25, 20:27
mlRe: Finding a relative date Nir Soffer Feb 25, 20:39
mlRe: Finding a relative date Nick Zitzmann Feb 25, 20:57
mlRe: Finding a relative date Deborah Goldsmith Feb 26, 00:49
mlRe: Finding a relative date Paul Bruneau Feb 26, 14:45
mlRe: Finding a relative date Deborah Goldsmith Feb 26, 21:39