QDate::fromString() fails on certain dates
Unsolved
General and Desktop
-
Qt 5.15, Qt 6.0, macOS 11.2 Big Sur. These conversions yield invalid dates:
qDebug() << QDate::fromString("1978-04-02", "yyyy-MM-dd"); qDebug() << QDate::fromString("02-04-1978", "dd-MM-yyyy");code_text
The following search yields four similar situations (1977-03-27, 1978-04-02, 1979-04-01,
1980-03-30):QString format("yyyy-MM-dd"); for (int year=1930; year <= 2030; ++year) { QDate date(year,1,1); while (date != QDate(year+1,1,1)) { QString str = date.toString(format); QDate converted = QDate::fromString(str, format); if (converted != date) qDebug() << date << converted; date = date.addDays(1); } }
Any ideas?
-
Create a bug report about this. Works fine on linux.
-
Hi and welcome to devnet,
Can you post the output you get ?
-