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

Qt lacks QTimeZone class for getting the local time zone

    XMLWordPrintable

Details

    Description

      Qt supports convering a QDateTime between local time and UTC, and to do that it obviously needs information about the current time zone.

      Right now, the best way to get the current time zone is

      QDateTime now = QDateTime::currentDateTime();
      int timezone = now.time().hour() - now.toUTC().time().hour();

      (which returns +1 if it's Winter and you are in Oslo). However, daylight saving will introduce an off-by-one error - Oslo is still in GMT+1, but the current time is adjusted.

      An API that returns the actual time zone would solve that problem, and would be more elegant than the code above anyway.

      Attachments

        Issue Links

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

          Activity

            People

              johnlayt John Layt
              vhilshei Volker Hilsheimer
              Votes:
              30 Vote for this issue
              Watchers:
              22 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes