When attempting to format a std::chrono::sys_time<Duration>, where Duration is not the same as std::chrono::system_clock::duration, compilation fails with the static assertion:
static_assert failed due to requirement '!std::is_same<const fmt::v7::detail::unformattable &, const fmt::v7::detail::unformattable &>::value' "Cannot format an argument. To make type T formattable provide a formatter specialization
Godbolt demo: https://godbolt.org/z/7Moc5cKrr
According to https://en.cppreference.com/w/cpp/chrono/system_clock/formatter, C++20's format accepts any duration type for sys_time.
hinnant/date's format accepts any arbitrary sys_time:
using time_type =
std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>;
time_type t{std::chrono::seconds{42}};
auto s = date::format(std::locale::classic(), "%S", t);
std::cout << s << "\n"; // prints 42
This is related to issue #2207 where one would want to std::chrono::floor a sys_time to the desired precision for formatting.
When attempting to format a
std::chrono::sys_time<Duration>, whereDurationis not the same asstd::chrono::system_clock::duration, compilation fails with the static assertion:Godbolt demo: https://godbolt.org/z/7Moc5cKrr
According to https://en.cppreference.com/w/cpp/chrono/system_clock/formatter, C++20's
formataccepts any duration type forsys_time.hinnant/date's
formataccepts any arbitrarysys_time:This is related to issue #2207 where one would want to
std::chrono::floorasys_timeto the desired precision for formatting.