It apparently breaks users' applications.

Task-number: QTBUG-33487

Change-Id: Iaeceb3a02b5c7b9ab839c14693aaffcdf9394bc6
Reviewed-by: John Layt <jlayt@kde.org>
Reviewed-by: hjk <hjk121@nokiamail.com>
bb10
Mitch Curtis 2013-09-16 11:55:07 +02:00 committed by The Qt Project
parent 89294d04e2
commit 438912f273
4 changed files with 33 additions and 37 deletions

View File

@ -1583,12 +1583,12 @@ int QTime::msec() const
Returns the time as a string. The \a format parameter determines
the format of the string.
If \a format is Qt::TextDate, the string format is HH:MM:SS.zzz;
e.g. 1 second before midnight would be "23:59:59.000".
If \a format is Qt::TextDate, the string format is HH:MM:SS;
e.g. 1 second before midnight would be "23:59:59".
If \a format is Qt::ISODate, the string format corresponds to the
ISO 8601 extended specification (with decimal fractions) for
representations of dates; also HH:MM:SS.zzz.
ISO 8601 extended specification for representations of dates,
which is also HH:MM:SS.
If the \a format is Qt::SystemLocaleShortDate or
Qt::SystemLocaleLongDate, the string format depends on the locale
@ -1636,10 +1636,9 @@ QString QTime::toString(Qt::DateFormat format) const
case Qt::ISODate:
case Qt::TextDate:
default:
return QString::fromUtf8("%1:%2:%3.%4").arg(hour(), 2, 10, QLatin1Char('0'))
.arg(minute(), 2, 10, QLatin1Char('0'))
.arg(second(), 2, 10, QLatin1Char('0'))
.arg(msec(), 3, 10, QLatin1Char('0'));
return QString::fromUtf8("%1:%2:%3").arg(hour(), 2, 10, QLatin1Char('0'))
.arg(minute(), 2, 10, QLatin1Char('0'))
.arg(second(), 2, 10, QLatin1Char('0'));
}
}
@ -2729,15 +2728,15 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
and QTime::toString() are used to generate the string, so the
day and month names will be localized names using the system locale,
i.e. QLocale::system(). An example of this formatting is
"Wed May 20 03:40:13.456 1998".
"Wed May 20 03:40:13 1998".
If the \a format is Qt::ISODate, the string format corresponds
to the ISO 8601 extended specification (with decimal fractions) for
representations of dates and times, taking the form
YYYY-MM-DDTHH:MM:SS.zzz[Z|[+|-]HH:MM], depending on the timeSpec()
of the QDateTime. If the timeSpec() is Qt::UTC, Z will be appended
to the string; if the timeSpec() is Qt::OffsetFromUTC, the offset
in hours and minutes from UTC will be appended to the string.
to the ISO 8601 extended specification for representations of
dates and times, taking the form YYYY-MM-DDTHH:MM:SS[Z|[+|-]HH:MM],
depending on the timeSpec() of the QDateTime. If the timeSpec()
is Qt::UTC, Z will be appended to the string; if the timeSpec() is
Qt::OffsetFromUTC, the offset in hours and minutes from UTC will
be appended to the string.
If the \a format is Qt::SystemLocaleShortDate or
Qt::SystemLocaleLongDate, the string format depends on the locale

View File

@ -995,8 +995,8 @@ void tst_QVariant::toString_data()
QTest::newRow( "float" ) << QVariant( 123.456f ) << QString( "123.456" );
QTest::newRow( "bool" ) << QVariant( true ) << QString( "true" );
QTest::newRow( "qdate" ) << QVariant( QDate( 2002, 1, 1 ) ) << QString( "2002-01-01" );
QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56.000" );
QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56.000" );
QTest::newRow( "qtime" ) << QVariant( QTime( 12, 34, 56 ) ) << QString( "12:34:56" );
QTest::newRow( "qdatetime" ) << QVariant( QDateTime( QDate( 2002, 1, 1 ), QTime( 12, 34, 56 ) ) ) << QString( "2002-01-01T12:34:56" );
QTest::newRow( "llong" ) << QVariant( (qlonglong)Q_INT64_C(123456789012) ) <<
QString( "123456789012" );
QTest::newRow("QJsonValue") << QVariant(QJsonValue(QString("hello"))) << QString("hello");

View File

@ -631,25 +631,22 @@ void tst_QDateTime::toString_isoDate_data()
QTest::newRow("localtime")
<< QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34))
<< QString("1978-11-09T13:28:34.000");
<< QString("1978-11-09T13:28:34");
QTest::newRow("UTC")
<< QDateTime(QDate(1978, 11, 9), QTime(13, 28, 34), Qt::UTC)
<< QString("1978-11-09T13:28:34.000Z");
<< QString("1978-11-09T13:28:34Z");
QDateTime dt(QDate(1978, 11, 9), QTime(13, 28, 34));
dt.setOffsetFromUtc(19800);
QTest::newRow("positive OffsetFromUTC")
<< dt
<< QString("1978-11-09T13:28:34.000+05:30");
<< QString("1978-11-09T13:28:34+05:30");
dt.setUtcOffset(-7200);
QTest::newRow("negative OffsetFromUTC")
<< dt
<< QString("1978-11-09T13:28:34.000-02:00");
<< QString("1978-11-09T13:28:34-02:00");
QTest::newRow("invalid")
<< QDateTime(QDate(-1, 11, 9), QTime(13, 28, 34), Qt::UTC)
<< QString();
QTest::newRow("999 milliseconds UTC")
<< QDateTime(QDate(2000, 1, 1), QTime(13, 28, 34, 999), Qt::UTC)
<< QString("2000-01-01T13:28:34.999Z");
}
void tst_QDateTime::toString_isoDate()
@ -684,15 +681,15 @@ void tst_QDateTime::toString_textDate_data()
QTest::addColumn<QString>("expected");
QTest::newRow("localtime") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::LocalTime)
<< QString("Wed Jan 2 01:02:03.000 2013");
<< QString("Wed Jan 2 01:02:03 2013");
QTest::newRow("utc") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::UTC)
<< QString("Wed Jan 2 01:02:03.000 2013 GMT");
<< QString("Wed Jan 2 01:02:03 2013 GMT");
QTest::newRow("offset+") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::OffsetFromUTC,
10 * 60 * 60)
<< QString("Wed Jan 2 01:02:03.000 2013 GMT+1000");
<< QString("Wed Jan 2 01:02:03 2013 GMT+1000");
QTest::newRow("offset-") << QDateTime(QDate(2013, 1, 2), QTime(1, 2, 3), Qt::OffsetFromUTC,
-10 * 60 * 60)
<< QString("Wed Jan 2 01:02:03.000 2013 GMT-1000");
<< QString("Wed Jan 2 01:02:03 2013 GMT-1000");
QTest::newRow("invalid") << QDateTime()
<< QString("");
}
@ -765,7 +762,7 @@ void tst_QDateTime::toString_enumformat()
QVERIFY(!str1.isEmpty()); // It's locale dependent everywhere
QString str2 = dt1.toString(Qt::ISODate);
QCOMPARE(str2, QString("1995-05-20T12:34:56.000"));
QCOMPARE(str2, QString("1995-05-20T12:34:56"));
QString str3 = dt1.toString(Qt::LocalDate);
QVERIFY(!str3.isEmpty());

View File

@ -677,14 +677,14 @@ void tst_QTime::toStringDateFormat_data()
QTest::addColumn<Qt::DateFormat>("format");
QTest::addColumn<QString>("expected");
QTest::newRow("00:00:00.000") << QTime(0, 0, 0, 0) << Qt::TextDate << QString("00:00:00.000");
QTest::newRow("ISO 00:00:00.000") << QTime(0, 0, 0, 0) << Qt::ISODate << QString("00:00:00.000");
QTest::newRow("Text 10:12:34.000") << QTime(10, 12, 34, 0) << Qt::TextDate << QString("10:12:34.000");
QTest::newRow("ISO 10:12:34.000") << QTime(10, 12, 34, 0) << Qt::ISODate << QString("10:12:34.000");
QTest::newRow("Text 10:12:34.001") << QTime(10, 12, 34, 001) << Qt::TextDate << QString("10:12:34.001");
QTest::newRow("ISO 10:12:34.001") << QTime(10, 12, 34, 001) << Qt::ISODate << QString("10:12:34.001");
QTest::newRow("Text 10:12:34.999") << QTime(10, 12, 34, 999) << Qt::TextDate << QString("10:12:34.999");
QTest::newRow("ISO 10:12:34.999") << QTime(10, 12, 34, 999) << Qt::ISODate << QString("10:12:34.999");
QTest::newRow("00:00:00.000") << QTime(0, 0, 0, 0) << Qt::TextDate << QString("00:00:00");
QTest::newRow("ISO 00:00:00.000") << QTime(0, 0, 0, 0) << Qt::ISODate << QString("00:00:00");
QTest::newRow("Text 10:12:34.000") << QTime(10, 12, 34, 0) << Qt::TextDate << QString("10:12:34");
QTest::newRow("ISO 10:12:34.000") << QTime(10, 12, 34, 0) << Qt::ISODate << QString("10:12:34");
QTest::newRow("Text 10:12:34.001") << QTime(10, 12, 34, 001) << Qt::TextDate << QString("10:12:34");
QTest::newRow("ISO 10:12:34.001") << QTime(10, 12, 34, 001) << Qt::ISODate << QString("10:12:34");
QTest::newRow("Text 10:12:34.999") << QTime(10, 12, 34, 999) << Qt::TextDate << QString("10:12:34");
QTest::newRow("ISO 10:12:34.999") << QTime(10, 12, 34, 999) << Qt::ISODate << QString("10:12:34");
QTest::newRow("RFC2822Date") << QTime(10, 12, 34, 999) << Qt::RFC2822Date << QString("10:12:34");
}