Skip to content

Commit

Permalink
Don't assume that system_clock::now().count() == _Xtime_get_ticks() (
Browse files Browse the repository at this point in the history
…#3681)

Part of #1588.

`_Xtime_get_ticks` and `system_clock::now` would no longer be equal after a future leap second when #1520 is eventually fixed. This PR changes the clock used in `_To_timespec64_sys_10_day_clamped` to be consistent with code that consumes its result, e.g. `target` in https://github.com/microsoft/STL/blob/091cad2eaaa5bc25873eb7261cae57ab123592f3/stl/src/cond.cpp#L72-L80
  • Loading branch information
statementreply authored May 18, 2023
1 parent 77a336a commit 04db120
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion stl/inc/__msvc_chrono.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ _NODISCARD bool _To_timespec64_sys_10_day_clamped(
// Every function calling this one is TRANSITION, ABI
constexpr _CHRONO nanoseconds _Ten_days{_CHRONO hours{24} * 10};
constexpr _CHRONO duration<double> _Ten_days_d{_Ten_days};
_CHRONO nanoseconds _Tx0 = _CHRONO system_clock::now().time_since_epoch();
_CHRONO nanoseconds _Tx0 = _CHRONO system_clock::duration{_Xtime_get_ticks()};
const bool _Clamped = _Ten_days_d < _Rel_time;
if (_Clamped) {
_Tx0 += _Ten_days;
Expand Down

0 comments on commit 04db120

Please sign in to comment.