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

timezone: add /etc/TZ support

    XMLWordPrintable

Details

    • User Story
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12.2
    • Core: Date/Time
    • None
    • 0fb30652b54aa0d36b9720becd9f3c3deb7a7806 (qt/qtbase/dev)

    Description

      Many embedded system use uClibc, it use /etc/TZ and optionaly can fallback to /etc/localtime.

      Unfortunately at this moment QTimeZone class does not have it support, I prepare simple prototype, I hope this wil be usefull.

      src/corelib/tools/qtimezoneprivate_tz.cpp
      @@ -1050,6 +1050,20 @@ QByteArray QTzTimeZonePrivate::systemTimeZoneId() const
           if (ianaId == "/etc/localtime")
               ianaId.clear();
       
      +#ifdef __UCLIBC__
      +    // uclibc use /etc/TZ and support only POSIX timezone
      +    // it support fallback to /etc/localtime, but this is optional
      +    // http://leaf.sourceforge.net/doc/buci-tz3.html
      +    if (ianaId.isEmpty()) {
      +        QFile tzif(QStringLiteral("/etc/TZ"));
      +        if (tzif.open(QIODevice::ReadOnly)) {
      +            QTextStream ts(&tzif);
      +            if (!ts.atEnd())
      +                ianaId = ts.readLine().toUtf8();
      +        }
      +    }
      +#endif
      +
           // On most distros /etc/localtime is a symlink to a real file so extract name from the path

       

      Attachments

        1. timezone.cpp
          0.6 kB
          Kirill Brilliantov
        2. timezone.cpp
          0.8 kB
          Kirill Brilliantov
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Eddy Edward Welbourne
            imb Kirill Brilliantov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes