Converting times between time zones
In the previous recipe, we talked about C++20 support for working with calendars and expressing dates in the Gregorian calendar with the year_month_day
type and others from the chrono
library.
We also saw how to represent times of day with the time_of_day
type. However, in all these examples, we worked with the time points using the system clock, which measures Unix time and therefore uses UTC as the default time zone. However, we are usually interested in the local time and, sometimes, in the time in some other time zone. This is possible with the facilities added to the chrono
library to support time zones. In this recipe, you will learn about the most important functionalities of chrono's time zones.
Getting ready
Before continuing with this recipe, it is recommended that you read the previous one, Working with calendars, if you have not done so already.
How to do it…
You can do the following using the...