Hi
i have got a function with BOOL return value and 2 input (NSDateComponents *) parameters. My trouble is I have two NSDateComponents values and I want to know if the two date fall within the same calendar week. i tried the simplest solutions to solve problem, my idea was the following:
- (BOOL)isFunctionName:(NSDateComponents *)comp1 andParam:(NSDateComponents *)comp2 {
return (([comp1 week] == [comp2 week]) && ([comp1 year] == [comp2 year]));
}
but it's not correct. what way i can solve it ?
edited
so i have a function which makes datecomponents from dates.
-(NSDateComponents *)dateToDateComponents:(NSDate *)date {
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [gregorian components:unitFlags fromDate:date];
[gregorian release];
return dateComponents;
}
and i call it this way:
if ([self isFunctionName: [self dateToDateComponents:startDate] and Param:[self dateToDateComponents:currentTripDate]]){
}
and during my test it returns YES all of my dates (for example 2010.07.21 - 2010.08.18)