Skip to content

Commit 04db120

Browse files
Don't assume that system_clock::now().count() == _Xtime_get_ticks() (#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
1 parent 77a336a commit 04db120

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

stl/inc/__msvc_chrono.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ _NODISCARD bool _To_timespec64_sys_10_day_clamped(
703703
// Every function calling this one is TRANSITION, ABI
704704
constexpr _CHRONO nanoseconds _Ten_days{_CHRONO hours{24} * 10};
705705
constexpr _CHRONO duration<double> _Ten_days_d{_Ten_days};
706-
_CHRONO nanoseconds _Tx0 = _CHRONO system_clock::now().time_since_epoch();
706+
_CHRONO nanoseconds _Tx0 = _CHRONO system_clock::duration{_Xtime_get_ticks()};
707707
const bool _Clamped = _Ten_days_d < _Rel_time;
708708
if (_Clamped) {
709709
_Tx0 += _Ten_days;

0 commit comments

Comments
 (0)