diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-12-10 16:21:35 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2022-10-18 14:13:28 +0200 |
commit | 743035b76a120bde725f16b22571d71c68a1a780 (patch) | |
tree | b043e454faf353f0cd292d650ea4ded51130337c /src/widgets/widgets/qdatetimeedit.cpp | |
parent | 01b1155ac695218e1b3b944617e570c9a727e4c7 (diff) |
QDateTimeEdit: check setDigit()'s return value
This way we only apply a spring-forward fix when it's relevant.
Change-Id: I5fbbb68b6e474566e0497c6ae89d74097570dccc
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
Diffstat (limited to 'src/widgets/widgets/qdatetimeedit.cpp')
-rw-r--r-- | src/widgets/widgets/qdatetimeedit.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index fc5762e23c..ac4d4cdc8c 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2114,12 +2114,12 @@ QDateTime QDateTimeEditPrivate::stepBy(int sectionIndex, int steps, bool test) c const int oldDay = v.date().day(calendar); - setDigit(v, sectionIndex, val); /* - Stepping into a daylight saving time that doesn't exist, - so use the time that has the same distance from epoch. + Stepping into a daylight saving time that doesn't exist (setDigit() is + true when date and time are valid, even if the date-time returned + isn't), so use the time that has the same distance from epoch. */ - if (!v.isValid()) { + if (setDigit(v, sectionIndex, val) && !v.isValid()) { auto msecsSinceEpoch = v.toMSecsSinceEpoch(); // decreasing from e.g 3am to 2am would get us back to 3am, but we want 1am if (steps < 0 && sn.type & HourSectionMask) |