The standard leaves an uncertain era std::chrono::system_clock::time_point
.
There are three implementations of std::chrono::system_clock::time_point
that I know of:
All three of them are thin wrappers around Unix Time , which counts the number of seconds that have passed since 00:00:00. Coordinated Universal Time (UTC), Thursday January 1, 1970, not counting the seconds of the jump.
All of them are based on a signed 64-bit integral type. None of them are stable. lib ++ has a tick period of microseconds. libstdC ++ has a tick period of nanoseconds, and VS has a tick period of 0.1 microseconds.
In case this is useful, here is an article that demonstrates some formula that allows you to use an indefinite but ordinary era to convert back and forth from a civil calendar without going through time_t
.
The advantage of using std::chrono::system_clock::from_time_t
is that it is guaranteed to work by standard. The disadvantage is that in practice it will limit you to the accuracy of the second (although this accuracy is not defined).
The advantage of the assumption that the era of std::chrono::system_clock
is 1970-01-01, although it is not specified, is that you will be correct in all known implementations, and the accuracy available for this alternative is much higher. than the provided time_t
.
source share