2 ms·
This assumes you store seconds since the epoch started. On a Mac, "as a non-portable extension, the clock_gettime_nsec_np() function will return the clock valu
by eesmith 4y ago
This assumes you store seconds since the epoch started.
On a Mac, "as a non-portable extension, the clock_gettime_nsec_np() function will return the clock value in 64-bit nanoseconds":
uint64_t clock_gettime_nsec_np(clockid_t clock_id);
I believe it combines the two parameters from structure
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
to give the number of nanoseconds since 1 January 1970.
>>> import datetime
>>> datetime.datetime(1970, 1, 1, 0, 0, 0) + \
... datetime.timedelta(microseconds=(2**64-1) / 1000)
datetime.datetime(2554, 7, 21, 23, 34, 33, 709552)
That's only a bit over five centuries away.
Also, there appears to be a problem with the stated calculation. I get:
>>> (2**63-1 ) / 60 / 60 / 24 / 365.25
292271023045.3132
292,271,023,045 years is slightly shorter than the 292,277,026,596 years you quoted.
Using the more precise 1 year = 365.2425 days that lanna pointed out gives 292,277,024,626 years, still not what ChatGPT gave.
ChatGPT's result implies 1 year = 365.2424975393588 days.