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

CalendarModel::indexOf() returns wrong value when model month starts from February

    XMLWordPrintable

Details

    • Windows
    • 17d0bf258 (dev), 178fefa07 (6.5)

    Description

      Instructions on reproduce the issue

      Run attached test project and see application output. 
      Error output:

      qml: 1993-2->0
      qml: 1993-3->0
      qml: 1993-4->2
      qml: 1993-5->2
      qml: 1993-6->4
      qml: 1993-7->4
      qml: 1993-8->6
      qml: 1993-9->7
      qml: 1993-10->7
      qml: 1993-11->9
      qml: 1993-12->9
      qml: 1994-1->11
      qml: 1994-2->12
      qml: 1994-3->12
      qml: 1994-4->14
      qml: 1994-5->14
      qml: 1994-6->16
      qml: 1994-7->16
      qml: 1994-8->18
      qml: 1994-9->19
      qml: 1994-10->19
      qml: 1994-11->21
      qml: 1994-12->21 
      

      Expected output:

      qml: 1993-2->0
      qml: 1993-3->1
      qml: 1993-4->2
      qml: 1993-5->3
      qml: 1993-6->4
      qml: 1993-7->5
      qml: 1993-8->6
      qml: 1993-9->7
      qml: 1993-10->8
      qml: 1993-11->9
      qml: 1993-12->10
      qml: 1994-1->11
      qml: 1994-2->12
      qml: 1994-3->13
      qml: 1994-4->14
      qml: 1994-5->15
      qml: 1994-6->16
      qml: 1994-7->17
      qml: 1994-8->18
      qml: 1994-9->19
      qml: 1994-10->20
      qml: 1994-11->21
      qml: 1994-12->22 
      

       

      More detail

      This is a bug in our implementation:(in function QQuickCalendarModelPrivate::getCount, qquickcalendarmodel.cpp line 107)
       

          QDate r = QDate(1, 1, 1).addDays(days);
          int years = r.year() - 1;
          int months = r.month() - 1;
          return 12 * years + months + (r.day() / t.day());
      

      it uses days to calculation number of months, and when the date stops in February, there will only be 28 days and failed to add extra 1 to return value. Please also see attached test project's output.

      Attachments

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

        Activity

          People

            Eddy Edward Welbourne
            leonzh Leon Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes