4 Time points, duration, and literals
This chapter covers
- Using
std::chrono
time points and durations - Using ratios
- Using literal suffixes
- Using the overloaded
operator/
to create dates - Input and output of time points and durations
- Using different time zones
In this chapter, we will make a short program to create a countdown to an event. To do this, we will use time points and durations from the chrono
header. This feature was introduced in C++11, and although the essence has remained the same, several useful additions have been made over time. Howard Hinnant is the main author and designer of this feature. In his Meeting C++ talk in 2019, he gave a lot of background to its design (https://www.youtube.com/watch?v=adSAN282YIw). As we use chrono ...
Get Learn C++ by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.