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>: Fix utc_clock seconds formatting #1868

Merged
merged 5 commits into from
Apr 21, 2021

Conversation

eldakesh-ms
Copy link
Contributor

@eldakesh-ms eldakesh-ms commented Apr 20, 2021

Seconds were being formatted incorrectly because we incorrectly assumed
that a day is 24*60*60 seconds (which is what flooring does) when in
reality they aren't always (like if there was a leap second). This error
compounds over time as leap seconds are inserted, so we need to add the
elapsed leap seconds at any given time point to get the correct seconds.

This issue doesn't affect the tm structure because it is constructed
out of a system time (utc_clock::to_sys), which has 24*60*60 second
days.

@eldakesh-ms eldakesh-ms requested a review from a team as a code owner April 20, 2021 18:22
@mnatsuhara mnatsuhara added the chrono C++20 chrono label Apr 20, 2021
@eldakesh-ms
Copy link
Contributor Author

Additional fixes for offsetting into a leap second coming, but I need to get the other PRs landed.

Seconds were being formatted incorrectly because we incorrectly assumed
that a day is 24*60*60 seconds (which is what flooring does) when in
reality they aren't always (like if there was a leap second). This error
compounds over time as leap seconds are inserted, so we need to add the
elapsed leap seconds at any given time point to get the correct seconds.

This issue doesn't affect the `tm` structure because it is constructed
out of a system time (`utc_clock::to_sys`), which has 24*60*60 second
days.
stl/inc/chrono Outdated Show resolved Hide resolved
stl/inc/chrono Outdated Show resolved Hide resolved
stl/inc/chrono Outdated Show resolved Hide resolved
stl/inc/chrono Outdated Show resolved Hide resolved
stl/inc/chrono Outdated Show resolved Hide resolved
stl/inc/chrono Outdated Show resolved Hide resolved
StephanTLavavej and others added 3 commits April 20, 2021 16:55
Also fixes Clang compiler errors.

Co-authored-by: MattStephanson <68978048+MattStephanson@users.noreply.github.com>
@StephanTLavavej StephanTLavavej merged commit cec735c into microsoft:chronat2 Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chrono C++20 chrono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants