diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2016-12-15 10:57:17 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2017-06-20 09:54:07 +0000 |
commit | 68f19fb630dc02463c2d61fc511de7407687795e (patch) | |
tree | e060d222527b39cd4766c973aacc580e06fe7c2d /src/corelib/tools/qdatetime.cpp | |
parent | 02b7ec05d5713aec67577cebc18e5906b5a98598 (diff) |
QDateTimeParser: implement parsing of time-zone specifiers
The serialization of date-times understood time-zones (indicated by a
't' in a format string) but the parsing didn't (so viewed the 't' as a
literal element in the format string, not matched by the actual zone
it needs to parse), although some tests expected it to.
This made round-trip testing fail.
Implemented parsing of time-zones.
Re-enabled the formerly failing tests.
[ChangeLog][QtCore][QDateTime] Added support for parsing of time-zones.
Task-number: QTBUG-22833
Change-Id: Iddba7dca14cf9399587078d4cea19f9b95a65cf7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qdatetime.cpp')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index b09499d25b..b6f43f0864 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2221,6 +2221,26 @@ static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus) #endif // Q_OS_WIN } +#ifndef QT_BOOTSTRAPPED +/* + \internal + Implemented here to share qt_tzname() +*/ +int QDateTimeParser::startsWithLocalTimeZone(const QStringRef name) +{ + QDateTimePrivate::DaylightStatus zones[2] = { + QDateTimePrivate::StandardTime, + QDateTimePrivate::DaylightTime + }; + for (const auto z : zones) { + QString zone(qt_tzname(z)); + if (name.startsWith(zone)) + return zone.size(); + } + return 0; +} +#endif // QT_BOOTSTRAPPED + // Calls the platform variant of mktime for the given date, time and daylightStatus, // and updates the date, time, daylightStatus and abbreviation with the returned values // If the date falls outside the 1970 to 2037 range supported by mktime / time_t |