diff options
author | John Layt <jlayt@kde.org> | 2013-07-18 11:37:57 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-06 01:53:11 +0200 |
commit | 61b56a89a1cf8a388ff925492700e5eef019c3aa (patch) | |
tree | 4897244d0ca1b1b335e1c30d4016f3c3a38adfc3 /tests/auto/corelib/tools/qtime/tst_qtime.cpp | |
parent | 8b02a62685953ad1b1e35750187e3e857d9d3ccd (diff) |
QDateTime - Clean up Qt::DateFormat formatting and parsing
Clean-up the implementation of toString() and fromString() methods in
QDate, QTime and QDateTime code to be more consistent in ISODate and
TextDate behavior, especially when handling TimeSpec.
Reformat some code so all methods are consistent in appearance and
function to make maintenance easier.
This changes some corner-case behavior in TextDate and ISODate, but
this either fixes bugs or makes the behavior match the documentation.
Change-Id: I457aa1d7cd4f448cd9f8a2e80ec635f3cb98e58c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qtime/tst_qtime.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qtime/tst_qtime.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qtime/tst_qtime.cpp b/tests/auto/corelib/tools/qtime/tst_qtime.cpp index 675aeafc06..864f90b380 100644 --- a/tests/auto/corelib/tools/qtime/tst_qtime.cpp +++ b/tests/auto/corelib/tools/qtime/tst_qtime.cpp @@ -575,9 +575,12 @@ void tst_QTime::fromStringDateFormat_data() QTest::newRow("TextDate - data1") << QString("10:12:34") << Qt::TextDate << QTime(10,12,34,0); QTest::newRow("TextDate - data2") << QString("19:03:54.998601") << Qt::TextDate << QTime(19, 3, 54, 999); QTest::newRow("TextDate - data3") << QString("19:03:54.999601") << Qt::TextDate << QTime(19, 3, 54, 999); + QTest::newRow("TextDate - data4") << QString("10:12") << Qt::TextDate << QTime(10, 12, 0, 0); QTest::newRow("TextDate - invalid, minutes") << QString::fromLatin1("23:XX:00") << Qt::TextDate << invalidTime(); + QTest::newRow("TextDate - invalid, minute fraction") << QString::fromLatin1("23:00.123456") << Qt::TextDate << invalidTime(); QTest::newRow("TextDate - invalid, seconds") << QString::fromLatin1("23:00:XX") << Qt::TextDate << invalidTime(); QTest::newRow("TextDate - invalid, milliseconds") << QString::fromLatin1("23:01:01:XXXX") << Qt::TextDate << QTime(23, 1, 1, 0); + QTest::newRow("TextDate - midnight 24") << QString("24:00:00") << Qt::TextDate << QTime(); QTest::newRow("IsoDate - valid, start of day, omit seconds") << QString::fromLatin1("00:00") << Qt::ISODate << QTime(0, 0, 0); QTest::newRow("IsoDate - valid, omit seconds") << QString::fromLatin1("22:21") << Qt::ISODate << QTime(22, 21, 0); @@ -599,6 +602,7 @@ void tst_QTime::fromStringDateFormat_data() QTest::newRow("IsoDate - data1") << QString("10:12:34") << Qt::ISODate << QTime(10,12,34,0); QTest::newRow("IsoDate - data2") << QString("19:03:54.998601") << Qt::ISODate << QTime(19, 3, 54, 999); QTest::newRow("IsoDate - data3") << QString("19:03:54.999601") << Qt::ISODate << QTime(19, 3, 54, 999); + QTest::newRow("IsoDate - midnight 24") << QString("24:00:00") << Qt::ISODate << QTime(0, 0, 0, 0); QTest::newRow("IsoDate - minute fraction midnight") << QString("24:00,0") << Qt::ISODate << QTime(0, 0, 0, 0); // Test Qt::RFC2822Date format (RFC 2822). |