The accuracy of the values depend on the used clock: std::system::system_clock, std::chrono::steady_clock or std::chrono::high_resolution_clock.

C++ gives no guarantee about the accuracy, the starting point or the valid time range of a clock. The starting point of std::chrono::system_clock is typically the 1.1.1970, the so called UNIX-epoch. It holds further that std::chrono::high_resolution clock has the highest accuracy.

For the sake of the readability I introduced the namespace std::chrono. The output of the program shows that an overflow of the time points in line 24 and 27 causes wrong results. Subtracting 1000 years from the current time point gives a time point in the future; adding 1000 years to the current time point gives a time point in the past, respectively.

What's next?

The difference between two time points is a time duration. Time durations supports the basic arithmetic and can be displayed in different time ticks. How? Wait for the next post.

Go to Leanpub/cpplibrary"What every professional C++ programmer should know about the C++ standard library".Get your e-book. Support my blog.