//获取对应日期是周几
+ (NSInteger)getWeekDayFromDate:(NSDate *)date{
NSArray *tempWeek = @[@"7",@"1",@"2",@"3",@"4",@"5",@"6"];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *comps = [[NSDateComponents alloc] init];
NSInteger unitFlags = NSCalendarUnitYear |NSCalendarUnitMonth |
NSCalendarUnitDay |NSCalendarUnitWeekday | NSCalendarUnitHour
|NSCalendarUnitMinute |NSCalendarUnitSecond;
comps = [calendar components:unitFlags fromDate:date];
// 1、2、3、4、5、6、7 分别对应 周日、周一、周二、周三、周四、周五、周六
NSInteger week = [comps weekday];
NSLog(@"---%ld",week);
// 调整后 1 代表 周一
return [tempWeek[week-1] integerValue] ;
}