I have always found that weeks seem to be handled weirdly in iOS.
weekOfMonth will be 1, 2, 3, 4, etc.
weekOfYear will be from 1 to 52 (I think)
They are apparently not measures of duration. Just like โApril 3โ is not a measurement of duration, while โ1 dayโ is a measurement of duration.
The best way to add one week is ...
NSCalendar *calendar = [NSCalendar currentCalendar]; NSDate *currentDate = [NSDate date]; NSDateComponents *comps = [[NSDateComponents alloc] init]; [comps setDay:7]; NSDate *date = [calendar dateByAddingComponents:comps toDate:currentDate options:0];
EDIT
After a little test, I was right.
NSDate *date = [NSDate date]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *comps = [calendar components:NSCalendarUnitWeekOfMonth | NSCalendarUnitWeekOfYear fromDate:date]; Printing description of date: 2014-08-20 08:15:13 +0000 Printing description of comps: <NSDateComponents: 0xb7753c0> Week of Year: 34 Week of Month: 4
Fogmeister
source share