Closed
Description
When calling the (experimental-library feature) std::chrono::time_zone::to_sys() with a 'nonexistent time' (daylight saving) the hour is corrected, but the minute part remains.
According to https://en.cppreference.com/w/cpp/chrono/time_zone/to_sys the correct behaviour would be: "If tp represents a nonexistent time between two UTC time_points, those two time_points will be the same, and that time_point will be returned."
Example
int main()
{
using namespace std::literals;
const std::chrono::time_zone* specificTimeZone = std::chrono::get_tzdb().locate_zone("Europe/Vienna");
{
const std::chrono::local_seconds inpTime{ std::chrono::local_days{ 2024y / std::chrono::March / 31d } + 2h + 0min };
const std::chrono::sys_seconds experimentalSystemTimestamp = specificTimeZone->to_sys(inpTime, std::chrono::choose::earliest);
std::cout << "UTC Timestamp: " << experimentalSystemTimestamp << std::endl;
}
{
const std::chrono::local_seconds inpTime{ std::chrono::local_days{ 2024y / std::chrono::March / 31d } + 2h + 30min };
const std::chrono::sys_seconds experimentalSystemTimestamp = specificTimeZone->to_sys(inpTime, std::chrono::choose::earliest);
std::cout << "UTC Timestamp: " << experimentalSystemTimestamp << std::endl;
}
{
const std::chrono::local_seconds inpTime{ std::chrono::local_days{ 2024y / std::chrono::March / 31d } + 3h + 0min };
const std::chrono::sys_seconds experimentalSystemTimestamp = specificTimeZone->to_sys(inpTime, std::chrono::choose::earliest);
std::cout << "UTC Timestamp: " << experimentalSystemTimestamp << std::endl;
}
Output
UTC Timestamp: 2024-03-31 01:00:00
UTC Timestamp: 2024-03-31 01:30:00
UTC Timestamp: 2024-03-31 01:00:00
Expected output
I would expect all the local timestamps between 31.03.2024 02:00 and 3:00 being converted to the same UTC timestamp (2024-03-31 01:00:00).
Environment
- clang version 19.1.2
- compiled using -fexperimental-library
- RHEL 9.4
Metadata
Metadata
Assignees
Type
Projects
Status
Done