Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-26038 Make Date/Time adhere to ISO 8601
  3. QTBUG-25387

QDateTime fromString ISO 8601 midnight issue

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0 RC 1
    • Core: Date/Time
    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mitch_curtis Mitch Curtis
            aahlborg Marcus Ahlberg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes