Details
-
Sub-task
-
Resolution: Done
-
P3: Somewhat important
-
None
-
Windows 7, Qt 4.8.0, Qt Creator 2.4.1, MSVC 2010
-
I391db0da755dbc822ba0820c302a2c10391e1f3b Ib742fe80686aff3c3770b995678cf838fb4e3bb4
Description
QDateTime handles the midnight notation "24:00" incorrectly. According to the standard, 24:00 one day is equivalent to 00:00 the next day.
From Wikipedia:
"Midnight is a special case and can be referred to as both "00:00" and "24:00". The notation "00:00" is used at the beginning of a calendar day and is the more frequently used. At the end of a day use "24:00". Note that "2007-04-05T24:00" is the same instant as "2007-04-06T00:00" (see Combined date and time representations below)."
Also see section 4.2.3 in http://dotat.at/tmp/ISO_8601-2004_E.pdf
This code:
QString testStr = "2012-02-23T24:00:00";
qDebug() << "QString:\t" << testStr;
QDateTime dateTime = QDateTime::fromString(testStr, Qt::ISODate);
qDebug() << "QDateTime:\t" << dateTime.toString(Qt::ISODate);
produces this output:
QString: "2012-02-23T24:00:00"
QDateTime: "2012-02-23T00:00:00"
According to the standard, the output should have been:
QString: "2012-02-23T24:00:00"
QDateTime: "2012-02-24T00:00:00"
Attachments
For Gerrit Dashboard: QTBUG-25387 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
27865,1 | Allow 24:00:00 for ISO dates in QDateTime::fromString(). | master | qt/qtbase | Status: MERGED | +2 | 0 |
28818,2 | Make QDateTime::fromString()/Time::fromString() adhere to ISO 8601. | master | qt/qtbase | Status: MERGED | +2 | 0 |