-(NSString *)outputWeek{
NSInteger year,month,day,hour,min,sec,week;
NSString *weekStr=nil;
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDate *now = [NSDate date];;
NSDateComponents *comps = [[NSDateComponents alloc] init];
NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday |
NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
comps = [calendar components:unitFlags fromDate:now];
year = [comps year];
week = [comps weekday];
month = [comps month];
day = [comps day];
hour = [comps hour];
min = [comps minute];
sec = [comps second];
if(week==1)
{
weekStr=@"星期天";
}else if(week==2){
weekStr=@"星期一";
}else if(week==3){
weekStr=@"星期二";
}else if(week==4){
weekStr=@"星期三";
}else if(week==5){
weekStr=@"星期四";
}else if(week==6){
weekStr=@"星期五";
}else if(week==7){
weekStr=@"星期六";
}
else {
NSLog(@"error!");
}
NSLog(@"现在是:%ld年%ld月%ld日 %ld时%ld分%ld秒 %@",(long)year,(long)month,(long)day,(long)hour,(long)min,(long)sec,weekStr);
NSInteger Monday = day - week+1+1;
for (int i=1; i<=7; i++) {
NSLog(@"本周 星期%d :%ld年%ld月%ld日 ",i,(long)year,(long)month,(long)Monday);
Monday=Monday+1;
}
return @"setDate";
}