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

QTime::fromString returns tenths of seconds instead of milliseconds

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.9.2
    • 4.8.7, 5.6.1, 5.8.0
    • Core: Date/Time
    • Ubuntu 16.04 64 bit
      Windows 7 64 bit MSVC2013 32 bit
    •  bcd19b723a4adad4d5f1dbbd35079cc24331dfa8

    Description

      QTime::fromString allows the format "z" which is documented as: "the milliseconds without leading zeroes (0 to 999)".

      If you use this:

      #include <QTime>
      #include <QDebug>
      
      int main(int, char *[])
      {
          // six milliseconds, no leading zeros
          const QTime t = QTime::fromString("6", "z");
          qDebug() << t;
          qDebug() << t.msec() << "milliseconds";
          return 0;
      }
      

      you get the following output:

      QTime("00:00:00.600")
      600 milliseconds
      

      Instead the correct output would be:

      QTime("00:00:00.006")
      6 milliseconds
      

      Attachments

        For Gerrit Dashboard: QTBUG-53565
        # Subject Branch Project Status CR V

        Activity

          People

            thiago Thiago Macieira
            rlohning Robert Löhning
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes