<chrono>: `system_clock::now()` and `file_clock::from_utc()` interpret `FILETIME` in different ways
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
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):
https://github.com/microsoft/STL/blob/4ee3f91e06956ed2d8da4adcb8fcbf6bd75dc3b9/stl/inc/chrono#L666-L668
But file_clock::from_utc() and file_clock::to_utc() assume that FILETIME always counts leap seconds after 2017:
https://github.com/microsoft/STL/blob/4ee3f91e06956ed2d8da4adcb8fcbf6bd75dc3b9/stl/inc/chrono#L3324-L3325
We should fix all of them to return the correct result whether or not the system is leap second aware.
STL version
https://github.com/microsoft/STL/commit/4ee3f91e06956ed2d8da4adcb8fcbf6bd75dc3b9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the referenced system_clock::now(), file_clock::from_utc(), and file_clock::to_utc() sections in stl/inc/chrono around lines 666-668 and 3324-3325. Compare their FILETIME and leap-second assumptions, then investigate behavior on leap-second-aware and unaware Windows systems. Done means all three conversions produce consistent, correct results in both configurations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100