この出力時間が得られるのはなぜですか:
2013-01-12 18:24:37.783 コード テスト[10328:c07] 0001-01-01 17:12:52 +0000
このコードを実行すると:
NSCalendar *calendar = [NSCalendar currentCalendar];
calendar.timeZone = [NSTimeZone localTimeZone];
NSDateComponents *components = [calendar components:NSHourCalendarUnit fromDate:[NSDate date]];
components.hour = 17;
components.minute = 47;
components.second = 0;
NSDate *fire = [calendar dateFromComponents:components];
NSLog(@"%@", fire);
デフォルトのタイムゾーン、システムのタイムゾーンを試しました。そして、常に異なる分と秒の出力が得られます! さらに間違った日付0001-01-01!!!! 理由はありますか?
追加のテスト:
このコードを実行すると:
NSCalendar *calendar = [NSCalendar currentCalendar];
calendar.timeZone = [NSTimeZone localTimeZone];
NSDateComponents *components = [calendar components:NSHourCalendarUnit fromDate:[NSDate date]];
components.hour = (components.hour + 1) % 24;
components.minute = 0;
components.second = 0;
NSDate *fire = [calendar dateFromComponents:components];
NSLog(@"%@", fire);
次の出力が得られます。
2013-01-12 18:41:41.552 コード テスト [10648:c07] 0001-01-01 18:25:52 +0000
2013-01-12 18:42:16.274 コード テスト[10648:c07] 0001-01-01 18:25:52 +0000
2013-01-12 18:42:30.310 コード テスト[10648:c07] 0001-01-01 18:25:52 +0000