Friday, November 1, 2019

The Varying Date.distantFuture

Apple:

An NSDate object representing a date in the distant future (in terms of centuries).

Craig Hockenberry:

Date.distantFuture is fixed at “January 1, 4001 at 12:00:00 AM GMT” - that means its timeIntervalSince1970 (currently at 64,092,211,200) will change over time because of leap seconds.

Date/time will always be hard, unless the Earth stops moving.

In other words, even within the same run (not to mention when unarchiving), you can’t rely on two distant future dates being equal. So don’t use it as a sentinel value.

Nikolai Ruhe:

I think timeIntervalSinceReferenceDate (and 1970) works differently: It does not take leap seconds into account. Each day ends at an exact multiple of 86400. That means that a given timeInterval might point to one (normal), two or zero points in time (at leap seconds).

Update (2019-11-02): The value can also vary between OS releases.

Comments RSS · Twitter

Leave a Comment