I have encountered a strange parsing issue.
It looks like when there are fractions of a second present there have to be at least 4 digits after '.' or else time will be parsed as 00:00:00.
Also issue does NOT show when we remove timezone part
I don't know much about ISO 8601 standard much but as i was able to check on wiki all strings are correct with the standard. So is it a bug or ... ?
This code (Qt 4.6.3, tried on desktop and Simulator):
QString datetime1
("2010-08-06T18:34:14.3+02:00");
QString datetime2
("2010-08-06T18:34:14.386+02:00");
QString datetime3
("2010-08-06T18:34:14.386625+02:00");
qDebug() << datetime1;
qDebug() << datetime2;
qDebug() << datetime3;
qDebug() << datetime11.toString(Qt::ISODate);
qDebug() << datetime22.toString(Qt::ISODate);
qDebug() << datetime33.toString(Qt::ISODate);
QString datetime1("2010-08-06T18:34:14.3+02:00");
QString datetime2("2010-08-06T18:34:14.386+02:00");
QString datetime3("2010-08-06T18:34:14.386625+02:00");
qDebug() << datetime1;
qDebug() << datetime2;
qDebug() << datetime3;
QDateTime datetime11 = QDateTime::fromString(datetime1, Qt::ISODate);
QDateTime datetime22 = QDateTime::fromString(datetime2, Qt::ISODate);
QDateTime datetime33 = QDateTime::fromString(datetime3, Qt::ISODate);
qDebug() << datetime11.toString(Qt::ISODate);
qDebug() << datetime22.toString(Qt::ISODate);
qDebug() << datetime33.toString(Qt::ISODate);
To copy to clipboard, switch view to plain text mode
generates this output:
"2010-08-06T18:34:14.3+02:00"
"2010-08-06T18:34:14.386+02:00"
"2010-08-06T18:34:14.386625+02:00"
"2010-08-06T00:00:00"
"2010-08-06T00:00:00"
"2010-08-06T18:34:14"
"2010-08-06T18:34:14.3+02:00"
"2010-08-06T18:34:14.386+02:00"
"2010-08-06T18:34:14.386625+02:00"
"2010-08-06T00:00:00"
"2010-08-06T00:00:00"
"2010-08-06T18:34:14"
To copy to clipboard, switch view to plain text mode
Bookmarks