summaryrefslogtreecommitdiffstats
path: root/src/corelib/time
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2020-09-30 12:51:18 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2020-10-07 15:57:43 +0200
commit6404084b9c1eba20421ced02a123bec7b857f012 (patch)
tree02032d6df6095ba6aa52d941d96edc5cd7f87e07 /src/corelib/time
parente1e61daf39903b8b7595465c50a9871dea308f06 (diff)
Use start of day when wrapping 24:00 to the next day
Previously we used 0:0 on the next day, which might fall in a fall-back's gap. [ChangeLog][QtCore][QDateTime] When fromString() reads 24:00 in ISO format, it now uses the start of the next day, rather than 0:0 on the next day. This only makes a difference if the next day's first hour is skipped by a time-zone transition. Change-Id: Ib81feca5dc09fa735321b6ab76d5d118d6db6fd2 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/time')
-rw-r--r--src/corelib/time/qdatetime.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 3ddad29080..ff4c57b1f8 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -4773,8 +4773,8 @@ QDateTime QDateTime::fromString(QStringView string, Qt::DateFormat format)
QTime time = fromIsoTimeString(isoString, format, &isMidnight24);
if (!time.isValid())
return QDateTime();
- if (isMidnight24)
- date = date.addDays(1);
+ if (isMidnight24) // time is 0:0, but we want the start of next day:
+ return date.addDays(1).startOfDay(spec, offset);
return QDateTime(date, time, spec, offset);
}
case Qt::TextDate: {