Details
-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
4.6.2
-
None
-
Qt 4.6.2 for Windows
Windows XP SP 3 (Nokia Image :))
Qt Creator 1.3.1
Description
There seems to be a problem when using "ddd" format in QDateTime::fromString(). It only appears if "ddd" is combined with "d" or "dd" in the same date string, not with any other format tokens or even "dddd".
As a result, date strings where the both the day of the month and the short day name appear, such as "Thu 15 Apr 10 20:30:30", cannot be parsed.
Source code for testing:
#include <QtCore/QCoreApplication> #include <QDebug> #include <QLocale> #include <QDateTime> void dumpAndReadDate(const QString& formatString) { QString dateString; QDateTime now = QDateTime::currentDateTime(); QDateTime dateTime; //1st case, dump and re-read dateString = now.toString(formatString); qDebug() << "=============================================="; qDebug() << "Current datetime dumped w/ format:" << formatString << " is " << dateString; dateTime = QDateTime::fromString(dateString, formatString); qDebug() << "Reading back with format " << formatString << ":"; qDebug() << dateTime << ", isValid:" << dateTime.isValid(); qDebug() << "=============================================="; } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QLocale loc; qDebug() << "Country:" << loc.countryToString(loc.country()); dumpAndReadDate("ddd"); dumpAndReadDate("ddd MM"); dumpAndReadDate("ddd MM yy"); dumpAndReadDate("ddd MM d"); //false dumpAndReadDate("ddd MM dd"); //false dumpAndReadDate("ddd MM dddd"); //true return a.exec(); }
Use cases marked as "false" are the ones that fail. No use cases could fail here, since the current date is being serialized and read back using the same format string.
Locale is English/US, so nothing to see here as well.
Attachments
Issue Links
- relates to
-
QTBUG-11102 Problem in QDate::fromString/toString() with Qt::SystemLocaleLongDate
- Closed