summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/time
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2024-03-21 17:41:26 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2024-04-19 12:39:41 +0100
commit3e426182e2e8122d96b208702faaf3177f3a3081 (patch)
tree474d9455f2cb32218c67fae009c81b115c1fc7f7 /tests/auto/corelib/time
parentb87db4296cb5d41a9915f04cc7638f975836c046 (diff)
Fix end-of-parse fixup of two-digit year in QDateTimeParser
When a date string contains day of the week, day of the month, month and two-digit year, it was still possible to get a conflicting result in the default century instead of a consistent result in the next (in fact present) century. The actual logic needed to get the right year has to take into account all date fields. This is all worked out already in actualDate(), so delegate to it instead of trying to make do with just the year info. Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-123579 Change-Id: Id057128d8a0af9f3a7708d0ee173f854bb1a2a8e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Diffstat (limited to 'tests/auto/corelib/time')
-rw-r--r--tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
index 6c0733686d..f9c6afc795 100644
--- a/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
+++ b/tests/auto/corelib/time/qdatetime/tst_qdatetime.cpp
@@ -3117,6 +3117,9 @@ void tst_QDateTime::fromStringStringFormat_data()
<< u"Thu January 2004"_s << u"ddd MMMM yyyy"_s << 1900
<< QDate(2004, 1, 1).startOfDay();
}
+ QTest::newRow("yy=24/Mar/20") // QTBUG-123579
+ << u"Wed, 20 Mar 24 16:17:00"_s << u"ddd, dd MMM yy HH:mm:ss"_s << 1900
+ << QDateTime(QDate(2024, 3, 20), QTime(16, 17));
QTest::newRow("secs-conflict") << u"1020"_s << u"sss"_s << 1900 << QDateTime();
QTest::newRow("secs-split-conflict")
<< u"10hello20"_s << u"ss'hello'ss"_s << 1900 << QDateTime();