A time zone determines local civil time from a named region, its UTC offset, and calendar-time rules such as daylight saving. It lets countdowns measure the physical time between a current instant and a local event. section 4.4 section 4.5
Use time zones when a countdown or schedule must respect local clock changes:
- Choose a zone by an IANA name such as Europe/London, or use the computer's current zone. section 4.4
- Convert a system time to zoned or local time when displaying an event. section 4.4
- Convert the local event back to system time before subtracting the current instant; local-time arithmetic ignores offset shifts. section 4.4
A daylight-saving countdown
In Britain, the clock change on March 27, 2022 means that a countdown from 3 a.m. on March 27 to the next day is shorter than a full day. A UTC-based calculation reports the wrong local result; a zoned calculation accounts for the missing hour. section 4.4
Listing 4.15 Countdown in local time
std::chrono::system_clock::duration
countdown_in_local_time(std::chrono::system_clock::time_point now,
std::chrono::year_month_day date)
{
using namespace std::chrono;
auto sys_event = zoned_time(current_zone(),
local_days{ date }).get_sys_time(); #1
return sys_event - now; #2
}
Inspect a compact C++ countdown that constructs a local event in the current zone, obtains its system time, and subtracts the current instant. section 4.4



