From 0773176fc2e48a16100cf78b91f11ed69c24678f Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Mon, 2 Sep 2024 22:42:10 +0300 Subject: [PATCH] QTimer: fix calculation error in API docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The range guaranteed by std¹ for nanosecond resolution is ±292 years, not ±292 million. ¹ https://eel.is/c++draft/time.syn, https://en.cppreference.com/w/cpp/chrono/duration#Helper_types, std::cout << chrono::floor(nanoseconds::max()) << '\n'; Since, in general, there is no integer type with ≥ 45 bits, but < 64 bits, the practical limit for milliseconds remains, indeed, ±292 million, so the QDateTime docs don't need fixing. Change-Id: I5ae7f9706f147c6f490ba17b10cebe96426bbba2 Reviewed-by: Marc Mutz (cherry picked from commit 051488c5faf5410e938978d4c1609c7a85074c57) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qtimer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp index 9b23cc28fb2..683b6dd1f9d 100644 --- a/src/corelib/kernel/qtimer.cpp +++ b/src/corelib/kernel/qtimer.cpp @@ -78,7 +78,7 @@ QT_BEGIN_NAMESPACE The maximum interval QTimer supports is limited by the number of milliseconds that would fit in an \c int (which is around 24 days); whereas QChronoTimer stores its interval as \c std::chrono::nanoseconds - (which raises that limit to around 292 million years), that is, there is + (which raises that limit to ±292 years), that is, there is less chance of integer overflow with QChronoTimer. \section1 Accuracy and Timer Resolution