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

QML Date.toUTCString() shows "GMT" string 2 times.

    XMLWordPrintable

Details

    Description

      When you run the following code

      Item {
          Component.onCompleted: console.log("DATE", (new Date()).toUTCString())
      }
      

      The result is:

      qml: DATE Fri Dec 5 21:07:01 2014 GMT GMT
      

      The problem code in qv4dateobject.cpp at line 597:

      static inline QString ToUTCString(double t)
      {
          if (std::isnan(t))
              return QStringLiteral("Invalid Date");
          return ToDateTime(t, Qt::UTC).toString() + QStringLiteral(" GMT");
      }
      

      in qdatetime.cpp

           case Qt::TextDate: {
              QDate dt;
              QTime tm;
              d->getDateTime(&dt, &tm);
              //We cant use date.toString(Qt::TextDate) as we need to insert the time before the year
              buf = QString::fromUtf8("%1 %2 %3 %4 %5").arg(dt.shortDayName(dt.dayOfWeek()))
                                                       .arg(dt.shortMonthName(dt.month()))
                                                       .arg(dt.day())
                                                       .arg(tm.toString(Qt::TextDate))
                                                       .arg(dt.year());
              if (timeSpec() != Qt::LocalTime) {
                  buf += QStringLiteral(" GMT");
                  if (d->m_spec == Qt::OffsetFromUTC)
                      buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
              }
              return buf;
          }
      

      so two functions are appending "GMT" string.

      Attachments

        Issue Links

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

          Activity

            People

              liaqi Liang Qi
              firatagdas Firat Agdas
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes