我的职务问题在于本周的mon日。
有时,它有一天:
+(NSDate *) lastMondayBeforeDate:(NSDate*)timeStamp {
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps =
[gregorian components:NSWeekdayCalendarUnit fromDate:timeStamp];
NSInteger weekday = [comps weekday];
weekday = weekday==1 ? 6 : weekday-2;
NSTimeInterval secondsSinceMondayMidnight =
(NSUInteger) [timeStamp timeIntervalSince1970] % 60*60*24 +
weekday * 60*60*24;
NSLog(@"MONDAY s DATE-----------%@", [timeStamp dateByAddingTimeInterval:-secondsSinceMondayMidnight]);
return [timeStamp dateByAddingTimeInterval:-secondsSinceMondayMidnight];
}