diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2011-01-11 12:26:18 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-01-11 12:26:18 (GMT) |
commit | 7afc73d1a894c2395ec8ba099adf4fb49ce561e3 (patch) | |
tree | 0c257ee135193e4eaf9df782639ee1d6b69624b2 /src | |
parent | 42f3142df03bc978a99fb0c41cd23c8b5a99569c (diff) | |
download | Qt-7afc73d1a894c2395ec8ba099adf4fb49ce561e3.zip Qt-7afc73d1a894c2395ec8ba099adf4fb49ce561e3.tar.gz Qt-7afc73d1a894c2395ec8ba099adf4fb49ce561e3.tar.bz2 |
deal with utcOffset in a correct way
like how we do that for ISO format
Reviewed-by: ddenis
Merge-request: 2536
Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 6a20c7a..9f71457 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3426,8 +3426,9 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) QString tz = parts.at(5); if (!tz.startsWith(QLatin1String("GMT"), Qt::CaseInsensitive)) return QDateTime(); - int tzoffset = 0; + QDateTime dt(date, time, Qt::UTC); if (tz.length() > 3) { + int tzoffset = 0; QChar sign = tz.at(3); if ((sign != QLatin1Char('+')) && (sign != QLatin1Char('-'))) { @@ -3442,8 +3443,9 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) tzoffset = (tzhour*60 + tzminute) * 60; if (sign == QLatin1Char('-')) tzoffset = -tzoffset; + dt.setUtcOffset(tzoffset); } - return QDateTime(date, time, Qt::UTC).addSecs(-tzoffset).toLocalTime(); + return dt.toLocalTime(); } #endif //QT_NO_TEXTDATE } |