diff options
author | Jens Georg <jensg@openismus.com> | 2011-04-13 08:14:43 (GMT) |
---|---|---|
committer | Zeno Albisser <zeno.albisser@nokia.com> | 2011-04-27 13:26:01 (GMT) |
commit | 8f95a19d330480bd86650c3d2e4e147d3bca5789 (patch) | |
tree | ac4a964e959fe422e19cc8fe906c64331a39d3bc /src/corelib/tools | |
parent | 2506b86828ca8140c2f22d85a4378df40899b132 (diff) | |
download | Qt-8f95a19d330480bd86650c3d2e4e147d3bca5789.zip Qt-8f95a19d330480bd86650c3d2e4e147d3bca5789.tar.gz Qt-8f95a19d330480bd86650c3d2e4e147d3bca5789.tar.bz2 |
Fix QDateTime::toString for Qt::ISODate
Fixes QTBUG-18290 and the "missing Z" from QTBUG-9698
Merge-request: 1149
Reviewed-by: Zeno Albisser <zeno.albisser@nokia.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index a3a8884..ff868c0 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2497,6 +2497,21 @@ QString QDateTime::toString(Qt::DateFormat f) const return QString(); // failed to convert buf += QLatin1Char('T'); buf += d->time.toString(Qt::ISODate); + switch (d->spec) { + case QDateTimePrivate::UTC: + buf += QLatin1Char('Z'); + break; + case QDateTimePrivate::OffsetFromUTC: { + int sign = d->utcOffset >= 0 ? 1: -1; + buf += QString::fromLatin1("%1%2:%3"). + arg(sign == 1 ? QLatin1Char('+') : QLatin1Char('-')). + arg(d->utcOffset * sign / SECS_PER_HOUR, 2, 10, QLatin1Char('0')). + arg((d->utcOffset / 60) % 60, 2, 10, QLatin1Char('0')); + break; + } + default: + break; + } } #ifndef QT_NO_TEXTDATE else if (f == Qt::TextDate) { |