summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-02-17 11:28:51 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-18 15:44:57 +0000
commit7e3c6465770ab346764bf51ab2edd745390eb7d6 (patch)
tree52667e720422586934982b5c217ba9122c5af8a8
parent8ae64f3d08bcf124b54f4a4369cf916c14c5d4e2 (diff)
Correct qt_mktime()'s check for last second in 1969
It was comparing time->second() to MSECS_PER_DAY - 1, but time->second() is the second within its minute, so is at most 59. It should be comparing seconds into the day to SECS_PER_DAY - 1. Prompted by a PVS-studio article. Change-Id: I1802c49fa18818f4b4fe74f187da5f799df7d1de Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 94b9ee03b5646bf58c12337bbc44e38265ad15a2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/time/qdatetime.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index f85e4115bb..62a5531c03 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -2485,7 +2485,7 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
*abbreviation = qt_tzname(QDateTimePrivate::StandardTime);
}
} else if (yy == 1969 && mm == 12 && dd == 31
- && time->second() == MSECS_PER_DAY - 1) {
+ && QTime(0, 0).secsTo(*time) == SECS_PER_DAY - 1) {
// There was, of course, a last second in 1969, at time_t(-1); we won't
// rescue it if it's not in normalised form, and we don't know its DST
// status (unless we did already), but let's not wantonly declare it