From dd978a5e0fc210321606b2385ff994f73790930e Mon Sep 17 00:00:00 2001 From: Vitaly Zaitsev Date: Wed, 28 Jun 2023 15:18:44 +0200 Subject: [PATCH] Added upstream patch with time_point fixes. --- fmt-10.0.0-time_point-fix.patch | 63 +++++++++++++++++++++++++++++++++ fmt.spec | 8 ++++- 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 fmt-10.0.0-time_point-fix.patch diff --git a/fmt-10.0.0-time_point-fix.patch b/fmt-10.0.0-time_point-fix.patch new file mode 100644 index 0000000..4c30040 --- /dev/null +++ b/fmt-10.0.0-time_point-fix.patch @@ -0,0 +1,63 @@ +From d7592ad8bfa41eda239497f672ae8dc7bda00a4b Mon Sep 17 00:00:00 2001 +From: Patrick Geltinger +Date: Fri, 12 May 2023 00:25:21 +0200 +Subject: [PATCH] Fix time_point formatting for durations with certain ratios + (#3430) + +* Fix time_point formatting + +* Add timestamps_ratios tests +--- + include/fmt/chrono.h | 3 ++- + test/chrono-test.cc | 24 ++++++++++++++++++++++++ + 2 files changed, 26 insertions(+), 1 deletion(-) + +diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h +index 1a2a12cf767..43daeeb4d39 100644 +--- a/include/fmt/chrono.h ++++ b/include/fmt/chrono.h +@@ -2142,7 +2142,8 @@ struct formatter, + epoch - std::chrono::duration_cast(epoch)); + + if (subsecs.count() < 0) { +- auto second = std::chrono::seconds(1); ++ auto second = std::chrono::duration_cast( ++ std::chrono::seconds(1)); + if (epoch.count() < ((Duration::min)() + second).count()) + FMT_THROW(format_error("duration is too small")); + subsecs += second; +diff --git a/test/chrono-test.cc b/test/chrono-test.cc +index 8e2772fa0f6..33c0c2c6653 100644 +--- a/test/chrono-test.cc ++++ b/test/chrono-test.cc +@@ -850,6 +850,30 @@ TEST(chrono_test, utc_clock) { + } + #endif + ++TEST(chrono_test, timestamps_ratios) { ++ std::chrono::time_point ++ t1(std::chrono::milliseconds(67890)); ++ ++ EXPECT_EQ(fmt::format("{:%M:%S}", t1), "01:07.890"); ++ ++ std::chrono::time_point ++ t2(std::chrono::minutes(7)); ++ ++ EXPECT_EQ(fmt::format("{:%M:%S}", t2), "07:00"); ++ ++ std::chrono::time_point>> ++ t3(std::chrono::duration>(7)); ++ ++ EXPECT_EQ(fmt::format("{:%M:%S}", t3), "01:03"); ++ ++ std::chrono::time_point>> ++ t4(std::chrono::duration>(1)); ++ ++ EXPECT_EQ(fmt::format("{:%M:%S}", t4), "01:03"); ++} ++ + TEST(chrono_test, timestamps_sub_seconds) { + std::chrono::time_point>> diff --git a/fmt.spec b/fmt.spec index 97d486b..639037b 100644 --- a/fmt.spec +++ b/fmt.spec @@ -1,12 +1,15 @@ Name: fmt Version: 10.0.0 -Release: 1%{?dist} +Release: 2%{?dist} License: MIT Summary: Small, safe and fast formatting library for C++ URL: https://github.com/fmtlib/%{name} Source0: %{url}/archive/%{version}.tar.gz +# https://github.com/fmtlib/fmt/commit/d7592ad8bfa41eda239497f672ae8dc7bda00a4b +Patch100: %{name}-10.0.0-time_point-fix.patch + BuildRequires: cmake BuildRequires: gcc BuildRequires: gcc-c++ @@ -60,6 +63,9 @@ This package contains the header file for using %{name}. %{_libdir}/pkgconfig/%{name}.pc %changelog +* Wed Jun 28 2023 Vitaly Zaitsev - 10.0.0-2 +- Added upstream patch with time_point fixes. + * Wed May 10 2023 Vitaly Zaitsev - 10.0.0-1 - Updated to version 10.0.0.