diff --git a/stl/inc/chrono b/stl/inc/chrono index e4850fd835..c65489db55 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -6467,8 +6467,9 @@ struct formatter<_CHRONO file_time<_Duration>, _CharT> { template 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: diff --git a/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp b/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp index b16ef15005..2d3a9757be 100644 --- a/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp +++ b/tests/std/tests/P0355R7_calendars_and_time_zones_formatting/test.cpp @@ -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