Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<chrono>: system_clock::now() and file_clock::from_utc() interpret FILETIME in different ways #1822

Open
statementreply opened this issue Apr 10, 2021 · 0 comments
Labels
bug Something isn't working chrono C++20 chrono

Comments

@statementreply
Copy link
Contributor

statementreply commented Apr 10, 2021

Describe the bug
In old Windows versions, FILETIME didn't count leap seconds. Since Windows 10 1809, Windows has become aware of leap seconds, and FILETIME counts leap seconds after 2018-06 by default (could be turned off system-wide to restore the old behavior).

Currently, system_clock::now() assumes the old behavior that FILETIME doesn't count leap seconds (#1520):

STL/stl/inc/chrono

Lines 666 to 668 in 4ee3f91

_NODISCARD static time_point now() noexcept { // get current time
return time_point(duration(_Xtime_get_ticks()));
}

But file_clock::from_utc() and file_clock::to_utc() assume that FILETIME always counts leap seconds after 2017:

STL/stl/inc/chrono

Lines 3324 to 3325 in 4ee3f91

// Assumes that FILETIME counts leap seconds only after the first 27 (i.e., after 1 January 2017), even though
// systems can opt out of this behavior.

We should fix all of them to return the correct result whether or not the system is leap second aware.

STL version
4ee3f91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working chrono C++20 chrono
Projects
None yet
2 participants