Time of Day
Understand how C++20 extends the chrono library to handle time of day, calendar dates, and time zones. Learn to use the std::chrono::hh_mm_ss type and related functions via Howard Hinnant's date library to manage and format time efficiently.
We'll cover the following...
🔑 Lack of compiler support
At the end of 2020, no C++ compiler supports the chrono extensions so far. Thanks to the prototype library date from Howard Hinnant, which is essentially a superset of the extended time functionality in C++20, you can experiment with it. The library is hosted on GitHub. There are various ways to use the date prototype:
You can try it out on Wandbox. Howard has uploaded the
date.hheader, which is sufficient to play with the new typestd::time_of_dayand the calendar. Here is Howard’s link: Try it out on Wandbox!.Copy the header
date.hinto the search path of your C++ compiler.Download the project and build it. The already mentioned GitHub page date gives you more information. This step is required when you want to try out the new time zone features.
The examples in this chapter use Howard Hinnant’s library. ...