简化方法如下:
- (BOOL)isChinaSameWeekAsDate: (NSDate *) aDate
{
NSDateComponents *components1 = [CURRENT_CALENDAR components:DATE_COMPONENTS fromDate:self];
NSDateComponents *components2 = [CURRENT_CALENDAR components:DATE_COMPONENTS fromDate:aDate];
NSInteger currentWeek = components1.weekOfYear;
NSInteger sourceWeek = components2.weekOfYear;
if (components1.weekday==1) {
currentWeek--;
}
if (components2.weekday==1) {
sourceWeek--;
}
if (currentWeek != sourceWeek) return NO;
return (fabs([self timeIntervalSinceDate:aDate]) < D_WEEK);
}
iOS - 判断一个日期与今天是否在同一周下面是我在工作中使用的计算某个日期与当前日期比较是否在同一周内,我现在感觉有点麻烦,不知道还有没有简单的方法,如果有欢迎给我留言,马上改正。 在网上看到有人只是比较了一下ye...