1

这是一个给我带来麻烦的代码序列:

NSLog(@"%@",date);
NSString *title = [NSString stringWithFormat:@"%2d", 
                   [[NSCalendar currentCalendar] components:CCCalendarUnits fromDate:date].day];
NSLog(@"%@ %@",title, [[NSCalendar currentCalendar] components:CCCalendarUnits fromDate:date]);

在哪里 : #define CCCalendarUnits NSYearCalendarUnit | NSMonthCalendarUnit | NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSDayCalendarUnit

和 2 个日志:日期:2012-10-27 21:00:00 +0000

2012-08-13 12:44:14.298 xxx[2561:207] 2012-10-27 21:00:00 +0000
2012-08-13 12:44:14.299 xxx[2561:207] 28 <NSDateComponents: 0x842fe00>
    Calendar Year: 2012
    Month: 10
    Day: 28
    Week (obsolescent): 44
    Weekday: 1

日期:2012-10-28 21:00:00

2012-08-13 12:44:14.299 365Quotes[2561:207] 2012-10-28 21:00:00 +0000
2012-08-13 12:44:14.300 365Quotes[2561:207] 28 <NSDateComponents: 0x82264a0>
        Calendar Year: 2012
        Month: 10
        Day: 28
        Week (obsolescent): 44
        Weekday: 1

您会注意到,对于两个日期(2012-10-27 21:00:00 +0000 和 2012-10-28 21:00:00 +0000),日期部分是相同的 (28)?任何帮助弄清楚为什么会这样?

谢谢

4

0 回答 0