Skip to content

Commit

Permalink
<chrono>: Adjust for leap seconds when formatting file_time (#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
statementreply authored Jun 29, 2021
1 parent a2e781b commit ac661bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -6469,8 +6469,9 @@ struct formatter<_CHRONO file_time<_Duration>, _CharT> {

template <class _FormatContext>
auto format(const _CHRONO file_time<_Duration>& _Val, _FormatContext& _FormatCtx) {
const auto _Sys = _CHRONO clock_cast<_CHRONO system_clock>(_Val);
return _Impl._Write(_FormatCtx, _Val, _Fill_tm(_Sys));
const auto _Utc = _CHRONO file_clock::to_utc(_Val);
const auto _Sys = _CHRONO utc_clock::to_sys(_Utc);
return _Impl._Write(_FormatCtx, _Utc, _Fill_tm(_Sys));
}

private:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ void test_clock_formatter() {
}
}
}

empty_braces_helper(file_clock::from_utc(utc_2016_12_31), STR("2016-12-31 00:00:00"));
empty_braces_helper(file_clock::from_utc(utc_2016_12_31) + 24h, STR("2017-01-01 00:00:00"));
empty_braces_helper(file_clock::from_utc(utc_2021_05_04), STR("2021-05-04 00:00:00"));
// TRANSITION: Test a leap second insertion after 2018-06 when there is one
}

template <typename CharT>
Expand Down

0 comments on commit ac661bf

Please sign in to comment.