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

QDateTimeEdit::setTimeSpec(Qt::UTC) converts UTC QDateTime as if it was a local time

    XMLWordPrintable

Details

    • 3379ace11b30d8e9a2c9b45789561ac44bf29c06

    Description

      With the following code I expect the QDateTimeEdit and the QString 's' to show "1st of January 2000 12:00:00", but it shows "1st of January 2000 11:00:00":

      QDateTime t(QDate(2000, 1, 1), QTime(12, 0, 0), Qt::UTC);
      QDateTimeEdit edit(t);
      edit.setTimeSpec(Qt::UTC);
      QString s = edit.dateTime().toString();
      

      My timezone is GMT+1. QDateTimeEdit::setTimeSpec() handles the QDateTime 't' as if it was a local time. But it is UTC. I consider this a bug.

      The following code works as expected:

      QDateTime t2(QDate(2000, 1, 1), QTime(12, 0, 0), Qt::UTC);
      QDateTimeEdit edit2;
      edit2.setTimeSpec(Qt::UTC);
      edit2.setDateTime(t2);
      QString s2 = edit2.dateTime().toString();
      

      Attachments

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

        Activity

          People

            Eddy Edward Welbourne
            yves Yves Strube
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes