Setting NSDateComponents results in incorrect NSDate

前端 未结 1 1268
鱼传尺愫
鱼传尺愫 2021-01-13 21:44

I\'m trying to get an NSDate object that has 21:00 as the local time - don\'t care about what day. I\'m scratching my head at this very strange result:

NSCa         


        
相关标签:
1条回答
  • 2021-01-13 22:19

    The problem is that railroad time wasn't implemented until November 18, 1883. You're neglecting to set a year so you're getting a date before that. Prior to the implementation of railroad time, the US time zones weren't exact hour differences from GMT. I'm not sure exactly what time zone Apple selects for you but whichever it was seems to have been adjusted by 7 minutes and 2 seconds upon the move to PST in 1883.

    0 讨论(0)
提交回复
热议问题