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> (cherry picked from commit 8f95a19d330480bd86650c3d2e4e147d3bca5789)
This commit is contained in:
parent
91ac13ceb7
commit
2528f4ffe5
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user