diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-12-30 17:39:21 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-01-02 09:58:44 +0100 |
commit | 0f315adf9199efcfafa44371464ab6d1fc866774 (patch) | |
tree | 35b67591255624c670aff0579e45b2973f56fd81 /src/corelib/tools/qdatetimeparser.cpp | |
parent | 2b0eb3fac319a17dd92903106d501f0f06df871f (diff) | |
parent | 52b85212a2ec8ec5bf187f6cd00b669a45bcf0bd (diff) |
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
.qmake.conf
sc/corelib/io/qfsfileengine_p.h
src/corelib/io/qstorageinfo_unix.cpp
src/platformsupport/eglconvenience/qeglpbuffer_p.h
src/platformsupport/input/libinput/qlibinputkeyboard.cpp
src/platformsupport/input/libinput/qlibinputpointer.cpp
src/plugins/platforms/cocoa/qcocoamenu.mm
src/plugins/platforms/ios/qiosscreen.h
src/plugins/platforms/ios/qioswindow.h
src/plugins/platforms/ios/quiview.mm
src/printsupport/dialogs/qpagesetupdialog_unix_p.h
src/printsupport/dialogs/qprintpreviewdialog.cpp
src/printsupport/widgets/qcupsjobwidget_p.h
src/widgets/widgets/qmenu.cpp
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
Change-Id: Iecb4883122efe97ef0ed850271e6c51bab568e9c
Diffstat (limited to 'src/corelib/tools/qdatetimeparser.cpp')
-rw-r--r-- | src/corelib/tools/qdatetimeparser.cpp | 48 |
1 files changed, 37 insertions, 11 deletions
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index f0c8b5a799..551e01e076 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -195,9 +195,11 @@ bool QDateTimeParser::setDigit(QDateTime &v, int index, int newVal) const return false; // Preserve zone: - v = (tspec == Qt::TimeZone - ? QDateTime(newDate, newTime, v.timeZone()) - : QDateTime(newDate, newTime, tspec, offset)); + v = +#if QT_CONFIG(timezone) + tspec == Qt::TimeZone ? QDateTime(newDate, newTime, v.timeZone()) : +#endif + QDateTime(newDate, newTime, tspec, offset); return true; } @@ -213,7 +215,9 @@ int QDateTimeParser::absoluteMax(int s, const QDateTime &cur) const { const SectionNode &sn = sectionNode(s); switch (sn.type) { +#if QT_CONFIG(timezone) case TimeZoneSection: return QTimeZone::MaxUtcOffsetSecs; +#endif case Hour24Section: case Hour12Section: return 23; // this is special-cased in // parseSection. We want it to be @@ -248,7 +252,9 @@ int QDateTimeParser::absoluteMin(int s) const { const SectionNode &sn = sectionNode(s); switch (sn.type) { +#if QT_CONFIG(timezone) case TimeZoneSection: return QTimeZone::MinUtcOffsetSecs; +#endif case Hour24Section: case Hour12Section: case MinuteSection: @@ -766,9 +772,11 @@ QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionIndex, text->replace(offset, used, sectiontext.constData(), used); break; } case TimeZoneSection: +#if QT_CONFIG(timezone) result = findTimeZone(sectionTextRef, currentValue, absoluteMax(sectionIndex), absoluteMin(sectionIndex)); +#endif break; case MonthSection: case DayOfWeekSectionShort: @@ -1091,17 +1099,21 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, int dayofweek = defaultDate.dayOfWeek(); Qt::TimeSpec tspec = defaultValue.timeSpec(); int zoneOffset = 0; // In seconds; local - UTC +#if QT_CONFIG(timezone) QTimeZone timeZone; +#endif switch (tspec) { case Qt::OffsetFromUTC: // timeZone is ignored zoneOffset = defaultValue.offsetFromUtc(); break; +#if QT_CONFIG(timezone) case Qt::TimeZone: timeZone = defaultValue.timeZone(); if (timeZone.isValid()) zoneOffset = timeZone.offsetFromUtc(defaultValue); // else: is there anything we can do about this ? break; +#endif default: // zoneOffset and timeZone are ignored break; } @@ -1126,9 +1138,11 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, { const QDate date = actualDate(isSet, year, year2digits, month, day, dayofweek); const QTime time = actualTime(isSet, hour, hour12, ampm, minute, second, msec); - sect = parseSection(tspec == Qt::TimeZone - ? QDateTime(date, time, timeZone) - : QDateTime(date, time, tspec, zoneOffset), + sect = parseSection( +#if QT_CONFIG(timezone) + tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) : +#endif + QDateTime(date, time, tspec, zoneOffset), index, pos, input); } @@ -1154,16 +1168,20 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, case TimeZoneSection: current = &zoneOffset; if (sect.used > 0) { - // Synchronize with what findTimeZone() found: +#if QT_CONFIG(timezone) // Synchronize with what findTimeZone() found: QStringRef zoneName = input->midRef(pos, sect.used); Q_ASSERT(!zoneName.isEmpty()); // sect.used > 0 - const QByteArray latinZone(zoneName.toLatin1()); + const QByteArray latinZone(zoneName == QLatin1String("Z") + ? QByteArray("UTC") : zoneName.toLatin1()); timeZone = QTimeZone(latinZone); tspec = timeZone.isValid() ? (QTimeZone::isTimeZoneIdAvailable(latinZone) ? Qt::TimeZone : Qt::OffsetFromUTC) : (Q_ASSERT(startsWithLocalTimeZone(zoneName)), Qt::LocalTime); +#else + tspec = Qt::LocalTime; +#endif } break; case Hour24Section: current = &hour; break; @@ -1321,9 +1339,11 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, const QDate date(year, month, day); const QTime time(hour, minute, second, msec); - return StateNode(tspec == Qt::TimeZone - ? QDateTime(date, time, timeZone) - : QDateTime(date, time, tspec, zoneOffset), + return StateNode( +#if QT_CONFIG(timezone) + tspec == Qt::TimeZone ? QDateTime(date, time, timeZone) : +#endif + QDateTime(date, time, tspec, zoneOffset), state, padding, conflicts); } @@ -1571,6 +1591,7 @@ QDateTimeParser::ParsedSection QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, int maxVal, int minVal) const { +#if QT_CONFIG(timezone) int index = startsWithLocalTimeZone(str); int offset; @@ -1597,6 +1618,10 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, while (index > 0) { str.truncate(index); + if (str == QLatin1String("Z")) { + offset = 0; // "Zulu" time - a.k.a. UTC + break; + } QTimeZone zone(str.toLatin1()); if (zone.isValid()) { offset = zone.offsetFromUtc(when); @@ -1609,6 +1634,7 @@ QDateTimeParser::findTimeZone(QStringRef str, const QDateTime &when, if (index > 0 && maxVal >= offset && offset >= minVal) return ParsedSection(Acceptable, offset, index); +#endif // timezone return ParsedSection(); } |