From 93bfa05382db1c119977793f6a2c73fdbecb380f Mon Sep 17 00:00:00 2001 From: Barry Revzin Date: Sat, 18 Mar 2023 09:16:22 -0500 Subject: [PATCH] %T is %H:%M:%S (#3349) --- include/fmt/chrono.h | 7 +++---- test/chrono-test.cc | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 0185bb81..11565d63 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1624,10 +1624,9 @@ class tm_writer { write2(tm_min()); } void on_iso_time() { - char buf[8]; - write_digit2_separated(buf, to_unsigned(tm_hour()), to_unsigned(tm_min()), - to_unsigned(tm_sec()), ':'); - out_ = copy_str(std::begin(buf), std::end(buf), out_); + on_24_hour_time(); + *out_++ = ':'; + on_second(numeric_system::standard, pad_type::unspecified); } void on_am_pm() { diff --git a/test/chrono-test.cc b/test/chrono-test.cc index cdd21319..c7edaff2 100644 --- a/test/chrono-test.cc +++ b/test/chrono-test.cc @@ -904,6 +904,8 @@ TEST(chrono_test, timestamps_sub_seconds) { EXPECT_EQ(fmt::format("{}.{}", strftime_full_utc(t9_sec), t9_sub_sec_part), fmt::format("{:%Y-%m-%d %H:%M:%S}", t9)); + EXPECT_EQ(fmt::format("{}.{}", strftime_full_utc(t9_sec), t9_sub_sec_part), + fmt::format("{:%Y-%m-%d %T}", t9)); const std::chrono::time_point