Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-56552

QDateTime/QTime truncates milliseconds when converting to Qt::ISODate string

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Fixed
    • Affects Version/s: 5.6, 5.7, 5.8, 5.9
    • Fix Version/s: 5.8.0, 5.15.4
    • Component/s: Core: Date/Time
    • Labels:
      None
    • Story Points:
      13
    • Commits:
      837781db52b59012fdebb357ccb3abbd2f9bf2f5

      Description

      QTime uses QString::asprintf("%02d:%02d:%02d", hour(), minute(), second()); when converting to a string for Qt::ISODate, but ISO 8601 includes possible milliseconds.

      This means that parsing a string into a QTime and outputting it again later will truncate milliseconds, potentially making two distinct events on the wire have the same timestamp when in reality they didn't.

      HH:mm:ss.zzz -> fromString(Qt::ISODate) -> QTime(HH, mm, ss, zzz) -> toString(Qt::ISODate) -> HH:mm:ss

      Workaround for 5.8 is to add a new enum Qt::ISODateWithMs that fixes the behaviour, without backwards-comparability issues.

      https://codereview.qt-project.org/#/c/163360

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              Eddy Edward Welbourne
              Reporter:
              vestbo Tor Arne Vestbø
              PM Owner:
              Maurice Kalinowski Maurice Kalinowski
              RnD Owner:
              Alex Blasche Alex Blasche
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews