From 382a7b99d466521b4f318eda3ea2d70471c170eb Mon Sep 17 00:00:00 2001 From: 0xArdi-N Date: Sat, 11 Nov 2023 13:25:01 +0700 Subject: [PATCH] handling fails when use minimum time_point --- include/fmt/chrono.h | 2 +- test/chrono-test.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 7bd4206d..89be0739 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -2088,7 +2088,7 @@ struct formatter, if (subsecs.count() < 0) { auto second = std::chrono::duration_cast(std::chrono::seconds(1)); - if (epoch.count() < ((Duration::min)() + second).count()) + if ((epoch + second).count() < ((Duration::min)() + second).count()) FMT_THROW(format_error("duration is too small")); subsecs += second; val -= second; diff --git a/test/chrono-test.cc b/test/chrono-test.cc index 07760688..dadd0af3 100644 --- a/test/chrono-test.cc +++ b/test/chrono-test.cc @@ -1002,4 +1002,4 @@ TEST(chrono_test, glibc_extensions) { EXPECT_EQ(fmt::format("{:%_S}", d), " 3.140000"); EXPECT_EQ(fmt::format("{:%-S}", d), "3.140000"); } -} +} \ No newline at end of file