diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2020-03-25 15:48:52 +0100 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2020-04-22 14:14:30 +0300 |
commit | 76054516047d8efb8529443830bb4d9ddf01010f (patch) | |
tree | b43f21e2828fb16fe5beb8a2298556d6a3da654d /src/widgets/widgets/qdatetimeedit_p.h | |
parent | 6c45b1817f1f56207dae8aa028b9cbb922dc8008 (diff) |
Handle specified time-spec in date-time parsing
When a date-time was parsed from a string, the result was equal (as a
date-time) to the correct value, but had (at least in some cases) the
wrong spec, where it should have had a spec reflecting the zone
specifier parsed.
The time-spec imposed for the benefit of QDateTimeEdit is now moved
from QDateTimeParser to QDateTimeEditPrivate, which takes over
responsibility for imposing it. QDateTimeParser assumes Qt::LocalTime
in member functions (where applicable) and uses the time-spec parsed
from the string when constructing the date-time.
QDateTime::fromString() and QLocale::toDateTime() are updated to
use the full QDateTime returned by QDateTimeParser.
Fixes: QTBUG-83075
Done-With: Edward Welbourne <edward.welbourne@qt.io>
Change-Id: I8b79add2c7fc13a200e1252d48dbfa70b36757bf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/widgets/widgets/qdatetimeedit_p.h')
-rw-r--r-- | src/widgets/widgets/qdatetimeedit_p.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 323246a87b..7df2b59710 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -98,12 +98,16 @@ public: { if (keyboardTracking) return minimum.toDateTime(); + if (spec != Qt::LocalTime) + return QDateTime(QDATETIMEEDIT_DATE_MIN.startOfDay(spec)); return QDateTimeParser::getMinimum(); } QDateTime getMaximum() const override { if (keyboardTracking) return maximum.toDateTime(); + if (spec != Qt::LocalTime) + return QDateTime(QDATETIMEEDIT_DATE_MIN.startOfDay(spec)); return QDateTimeParser::getMaximum(); } QLocale locale() const override { return q_func()->locale(); } @@ -148,6 +152,8 @@ public: #ifdef QT_KEYPAD_NAVIGATION bool focusOnButton; #endif + + Qt::TimeSpec spec = Qt::LocalTime; }; |