一年有几个星期?因为我在网上搜索过,发现一年总共有 52.1 周,但如果我在 Xcode 中这样做:
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setFirstWeekday:2];
NSDate* sourceDate = [NSDate date];
NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSTimeZone* destinationTimeZone = [NSTimeZone systemTimeZone];
NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:sourceDate];
NSInteger destinationGMTOffset = [destinationTimeZone secondsFromGMTForDate:sourceDate];
NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset;
NSDate* today = [[NSDate alloc] initWithTimeInterval:interval sinceDate:sourceDate];
NSDateComponents *todaysComponents = [gregorian components:NSWeekCalendarUnit fromDate:today];
NSUInteger todaysWeek = [todaysComponents week];
todaysWeek 值为:53,这怎么可能?为什么不是52?