請幫我不明顯代碼的行爲日期格式不正確?
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.hour = 15;
dateComponents.minute = 20;
dateComponents.calendar = calendar;
NSDate * endDate = [calendar dateFromComponents:dateComponents];
結束日期爲0001-01-01 12點49分43秒+0000。爲什麼?
由於時區不同,小時值可能不正確。爲什麼這樣奇怪的分鐘和秒鐘值? 此致敬禮。
如果我不得不猜測,我會說這是由01/01/0001以來日曆中積累的閏秒造成的,所以我會嘗試設置年份。但我只是做了這個,所以這可能是完全錯誤的。 –
有趣的...你可以打印日曆的時區屬性,特別是屬性。 'secondsFromGMT'和'abbreviation'。 –
@GuillaumeAlgis好主意! –