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

QDateTimeAxis::setRange doesn't preserve the TimeSpec

XMLWordPrintable

      If you use for instance UTC QDateTime and pass it to QDateTimeAxis::setRange, the time will changed internally to LocalTime, which will add an extra offset to time. For instance create a QDateTime like this 

          QDateTime minDt;
          QDateTime maxDt;
          minDt.setOffsetFromUtc(0);
          maxDt.setOffsetFromUtc(0);
          minDt.setMSecsSinceEpoch(0);
          maxDt.setMSecsSinceEpoch(8000);
      

      Where the value are like this

      minDt = QDateTime(1970-01-01 00:00:00.000 UTC Qt::TimeSpec(UTC)) , since epoc 0
      maxDt = QDateTime(1970-01-01 00:00:08.000 UTC Qt::TimeSpec(UTC)) , since epoc 8000
      

      When these are passed to QDateTimeAxis::setRange, the maxDt will end up to this

      QDateTime(1970-01-01 02:00:08.000 FLE Standard Time Qt::TimeSpec(LocalTime))
      

      Which has extra 2 hours in my case. See also the image.

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

            axelspoerl Axel Spoerl
            misalmel Mika Salmela
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes