From 76054516047d8efb8529443830bb4d9ddf01010f Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Wed, 25 Mar 2020 15:48:52 +0100 Subject: 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 Change-Id: I8b79add2c7fc13a200e1252d48dbfa70b36757bf Reviewed-by: Qt CI Bot Reviewed-by: Edward Welbourne --- src/corelib/time/qdatetimeparser_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/corelib/time/qdatetimeparser_p.h') diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h index 5c612ef6a4..f2795c31f0 100644 --- a/src/corelib/time/qdatetimeparser_p.h +++ b/src/corelib/time/qdatetimeparser_p.h @@ -85,7 +85,7 @@ public: }; QDateTimeParser(QMetaType::Type t, Context ctx, const QCalendar &cal = QCalendar()) : currentSectionIndex(-1), cachedDay(-1), parserType(t), - fixday(false), spec(Qt::LocalTime), context(ctx), calendar(cal) + fixday(false), context(ctx), calendar(cal) { defaultLocale = QLocale::system(); first.type = FirstSection; @@ -181,6 +181,7 @@ public: #if QT_CONFIG(datestring) StateNode parse(QString input, int position, const QDateTime &defaultValue, bool fixup) const; bool fromString(const QString &text, QDate *date, QTime *time) const; + bool fromString(const QString &text, QDateTime* datetime) const; #endif bool parseFormat(const QString &format); @@ -297,7 +298,6 @@ protected: // for the benefit of QDateTimeEditPrivate QLocale defaultLocale; QMetaType::Type parserType; bool fixday; - Qt::TimeSpec spec; // spec if used by QDateTimeEdit Context context; QCalendar calendar; }; -- cgit v1.2.3