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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 5.8.0, 5.15.4
    • 5.6, 5.7, 5.8, 5.9
    • Core: Date/Time
    • None
    • 13
    • 837781db52b59012fdebb357ccb3abbd2f9bf2f5

      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

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

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

              Created:
              Updated:
              Resolved: