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

QDate::toString() should explain QDate::shortDayName() and QDate::shortMonthName() will be localized name _using_ the default locale from the system.

    XMLWordPrintable

Details

    • 75249653108ea6c722a31395357b4e7feb7cd7b1, 4cf112b641f7ea9fb1ba87cefcef7ee98b6b0831

    Description

      Some important information is missing from QDate::toString(Qt::DateFormat format = Qt::TextDate) function, see http://doc.qt.digia.com/qt/qdate.html#toString page.

      If the format is Qt::TextDate, the string is formatted in the default way. QDate::shortDayName() and QDate::shortMonthName() are used to generate the string, so the day and month names will be localized names.

      We should add that "... localized name using the default locale from the system."

      Thus, below output is valid for German default locale set to system, but US locale set as default in the test application. As we can see from the Qt::TextDate case in toString() function, it is always using the month before date format, regardless of locale.

        QString::fromLatin1("%0 %1 %2 %3")
                      .arg(shortDayName(dayOfWeek()))
                      .arg(shortMonthName(m))
                      .arg(d)
                      .arg(y);
      
      ------------------------------------------------------------------------
      fDLShortDateString: "6/26/12"
      fDLShortDate: QDate("Mi Jun 26 1912")
      fDLShortDate.year(): 1912
      fDLShortDate.toString(): "Mi Jun 26 1912"
      Copied from Qt::TextDate case in QDate::toString(): "Mi Jun 26 1912"
      fDLShortDate.toJulianDay() 2419580
      ------------------------------------------------------------------------
      fDLLongDateString: "Sunday, June 26, 2112"
      fDLLongDate: QDate("So Jun 26 2112")
      fDLLongDate.year(): 2112
      fDLLongDate.toString(): "So Jun 26 2112"
      Copied from Qt::TextDate case in QDate::toString(): "So Jun 26 2112"
      fDLLongDate.toJulianDay() 2492629
      ------------------------------------------------------------------------
      

      Attachments

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

        Activity

          People

            leonlee Leonard Lee
            leonlee Leonard Lee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes