From 89dc1a1865dd8ed277b88a53262b79a93c2ba8dc Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 25 Mar 2020 15:46:32 +0100 Subject: Make t specifier for time-zone only apply to date-time It previously applied to dates and date-times, but was documented as applying to times (and date-times then included it by reference). It's only meaningful for a date-time. Change-Id: Id9e8e8cb987b03e5ddc77b05c581b9b6944065fc Reviewed-by: Thiago Macieira --- src/corelib/time/qdatetime.cpp | 12 +++++++++--- src/corelib/time/qdatetimeparser.cpp | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 8553f79d90..c2b741f7ca 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2533,7 +2533,6 @@ QT_WARNING_POP \row \li ap or a \li Interpret as an am/pm time. \e a/ap will match a lower-case version of either QLocale::amText() or QLocale::pmText(). - \row \li t \li the timezone (for example "CEST") \endtable All other input characters will be treated as text. Any non-empty sequence @@ -5478,8 +5477,15 @@ QT_WARNING_POP Uses the calendar \a cal if supplied, else Gregorian. - See QDate::fromString() and QTime::fromString() for the expressions - recognized in the format string to represent parts of the date and time. + In addition to the expressions, recognized in the format string to represent + parts of the date and time, by QDate::fromString() and QTime::fromString(), + this method supports: + + \table + \header \li Expression \li Output + \row \li t \li the timezone (for example "CEST") + \endtable + All other input characters will be treated as text. Any non-empty sequence of characters enclosed in single quotes will also be treated (stripped of the quotes) as text and not be interpreted as expressions. diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 3374b28b69..bc3d9b992e 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -525,7 +525,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat) } break; case 't': - if (parserType != QMetaType::QTime) { + if (parserType == QMetaType::QDateTime) { const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 }; newSectionNodes.append(sn); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); -- cgit v1.2.3