Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-60635

Previous/Next month calculation wrong in three-month view

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.4
    • 3.4
    • Calendar
    • MOODLE_34_STABLE
    • MOODLE_34_STABLE
    • MDL-60635-master
    • Hide

      This isn't the easiest to test. This code is historically in the renderer, and because it relates to dates and it's the dates that can be fruity, there no decent way to write a unit test, short of checking every single potential combination.

      I've written a quick test which runs through every day between 1/1/1970, and 31/12/2200 and confirms that the months are correct using the same code as supplied in the patch (but pulled out).

      1. Open the Calendar
      2. Click the "Calendar" link in breadcrumbs
        1. Confirm that the previous, current, and next months are shown
      3. Download https://gist.github.com/6dcb1811ecba88bdd89b5a1ba24ec7b0 and place in your dirroot
      4. Run is (CLI)
        1. Confirm that it only printed out a list of years, and did not print out any objects
      Show
      This isn't the easiest to test. This code is historically in the renderer, and because it relates to dates and it's the dates that can be fruity, there no decent way to write a unit test, short of checking every single potential combination. I've written a quick test which runs through every day between 1/1/1970, and 31/12/2200 and confirms that the months are correct using the same code as supplied in the patch (but pulled out). Open the Calendar Click the "Calendar" link in breadcrumbs Confirm that the previous, current, and next months are shown Download https://gist.github.com/6dcb1811ecba88bdd89b5a1ba24ec7b0 and place in your dirroot Run is (CLI) Confirm that it only printed out a list of years, and did not print out any objects

      When viewing the last day of a month with 31 days, it appears that something is getting the month calculation wrong and we end up with a three-month view of the calendar which has the same month twice. For example: October, October, November; instead of September, October, November.

      When I originally converted this view to use a template, I stripped out some old code which I didn't think was required. Apparently it was.

        1. after_patch.png
          123 kB
          Sara Arjona (@sarjona)
        2. before_patch.png
          120 kB
          Sara Arjona (@sarjona)

            dobedobedoh Andrew Lyons
            dobedobedoh Andrew Lyons
            Ankit Agarwal Ankit Agarwal
            Jun Pataleta Jun Pataleta
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.