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

QDate::fromString does not work with some formats in certain locales

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.9.2
    • Core: Date/Time
    • None
    • Windows

    Description

      QDate::fromString(config->date, "d-MMM-yyyy"); in a Japanese Locale did not work

      Traced issue to: int QDateTimeParser::sectionMaxSize(Section s, int count) const staring at line 618 in .cpp file

      const QLocale l = locale();
      const QLocale::FormatType format = count == 4 ? QLocale::LongFormat : QLocale::ShortFormat;
      for (int i=1; i<=mcount; ++i) {
          const QString str = (s == MonthSection ? l.monthName(i, format) : l.dayName(i, format));
          ret = qMax(str.size(), ret);
      } 
      

      the Japanese month names are all 2 characters long, the date I have specified has 3 characters.

      This results in an invalid date when it should not.  We should not use the local to specify the space allotted since in the format string we have already specified the width.  Alternatively we should specify the source locale of the string.  This string comes from a 3rd party source and is always in this format. 

      Thanks

       

      Attachments

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

        Activity

          People

            Eddy Edward Welbourne
            d.ferguson Daniel Ferguson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes