<pre name="code" class="objc">enum{
SUN = 1,
MON,
TEUS,
WED,
THUR,
FRI,
SAT,
};
- (NSString *)getWeek:(double)timeTemp{
NSDate * dateTime = [NSDate dateWithTimeIntervalSince1970:@(timeTemp).doubleValue];
NSCalendar * calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents * comps = [[NSDateComponents alloc] init];
NSInteger unitFlags = NSWeekdayCalendarUnit;
;
comps = [calendar components:unitFlags fromDate:dateTime];
return [self getWeekByWeekDay:[comps weekday]];
}
<pre name="code" class="objc">- (NSString *)getWeekByWeekDay:(NSInteger)weekday{
NSLog(@"%d",0x01<<weekday);
switch (weekday) {
case SUN:
return @"星期日";
break;
case MON:
return @"星期一";
break;
case TEUS:
return @"星期二";
break;
case WED:
return @"星期三";
break;
case THUR:
return @"星期四";
break;
case FRI:
return @"星期五";
break;
case SAT:
return @"星期六";
break;
default:
break;
}
return Nil;
}