Skip to content

Instantly share code, notes, and snippets.

@es-kumagai
Created August 8, 2012 07:53
Show Gist options
  • Save es-kumagai/3293276 to your computer and use it in GitHub Desktop.
Save es-kumagai/3293276 to your computer and use it in GitHub Desktop.
Get a date that after some weeks from a date. (iOS, Xcode 4.4.1, ARC)
- (NSDate*)dateAfterWeeks:(NSInteger)weeks fromDate:(NSDate*)date
{
NSCalendar* calendar = [NSCalendar currentCalendar];
NSDateComponents* someWeeksComponent = [[NSDateComponents alloc] init];
someWeeksComponent.week = weeks;
return [calendar dateByAddingComponents:someWeeksComponent toDate:date options:0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment