add a suffix for days and fix the one for minutes (#3664)
This commit is contained in:
parent
f76603f21e
commit
bb8d50f04b
@ -582,8 +582,9 @@ template <typename Period> FMT_CONSTEXPR inline const char* get_units() {
|
||||
if (std::is_same<Period, std::tera>::value) return "Ts";
|
||||
if (std::is_same<Period, std::peta>::value) return "Ps";
|
||||
if (std::is_same<Period, std::exa>::value) return "Es";
|
||||
if (std::is_same<Period, std::ratio<60>>::value) return "m";
|
||||
if (std::is_same<Period, std::ratio<60>>::value) return "min";
|
||||
if (std::is_same<Period, std::ratio<3600>>::value) return "h";
|
||||
if (std::is_same<Period, std::ratio<86400>>::value) return "d";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -454,8 +454,11 @@ TEST(chrono_test, format_default) {
|
||||
fmt::format("{}", std::chrono::duration<int, std::peta>(42)));
|
||||
EXPECT_EQ("42Es",
|
||||
fmt::format("{}", std::chrono::duration<int, std::exa>(42)));
|
||||
EXPECT_EQ("42m", fmt::format("{}", std::chrono::minutes(42)));
|
||||
EXPECT_EQ("42min", fmt::format("{}", std::chrono::minutes(42)));
|
||||
EXPECT_EQ("42h", fmt::format("{}", std::chrono::hours(42)));
|
||||
# if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907L
|
||||
EXPECT_EQ("42d", fmt::format("{}", std::chrono::days(42)));
|
||||
# endif
|
||||
EXPECT_EQ(
|
||||
"42[15]s",
|
||||
fmt::format("{}", std::chrono::duration<int, std::ratio<15, 1>>(42)));
|
||||
|
Loading…
Reference in New Issue
Block a user