diff options
Diffstat (limited to 'src/corelib/tools/qdatetime.cpp')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 6a20c7a..a3a8884 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -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 } |