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

Date Picker displays incorrect Month for Months with less than 31 days

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.2.5, 2.3.1, 2.4
    • Fix Version/s: 2.2.6, 2.3.3
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide

      Test pre-requisites

      • A few languages packs installed, including with non-enlish characters
      • Installing corresponding locales on your system `sudo locale-gen --no-archive ja_JP.UTF-8`
      • Set your machine date to the 31th of any month

      Test 1

      1. Go to your home page and switch to English language pack
      2. Go to the calendar, and add a new event
      3. Make sure that the pop-up date selector correctly displays each month
        • Correct month (February is not March, check that you'll never have two similar names while going from one month to another)

      Test 2

      1. Go to your home page and switch to a funky language pack
      2. Go to the calendar, and add a new event
      3. Make sure that the pop-up date selector correctly displays each month
        • Month and days are correctly translated
        • Correct month (February is not March, check that you'll never have two similar names while going from one month to another)

      Test 3

      1. Go to your home page and switch back to English
      2. Change your machine timezone to UTC-0800 or at least really different than the one previously used
      3. Go to the calendar, and add a new event
      4. Make sure that the pop-up date selector correctly displays each month
        • Month and days are correctly translated
        • Correct month (February is not March, check that you'll never have two similar names while going from one month to another)

      Test 4

      1. Go to your home page and switch back to English
      2. Change your user timezone to UTC-0800 or at least really different than the one previously used
      3. Go to the calendar, and add a new event
      4. Make sure that the pop-up date selector correctly displays each month
        • Month and days are correctly translated
        • Correct month (February is not March, check that you'll never have two similar names while going from one month to another)

      Test 5

      1. Reward yourself with a candy!
      Show
      Test pre-requisites A few languages packs installed, including with non-enlish characters Installing corresponding locales on your system `sudo locale-gen --no-archive ja_JP.UTF-8` Set your machine date to the 31th of any month Test 1 Go to your home page and switch to English language pack Go to the calendar, and add a new event Make sure that the pop-up date selector correctly displays each month Correct month (February is not March, check that you'll never have two similar names while going from one month to another) Test 2 Go to your home page and switch to a funky language pack Go to the calendar, and add a new event Make sure that the pop-up date selector correctly displays each month Month and days are correctly translated Correct month (February is not March, check that you'll never have two similar names while going from one month to another) Test 3 Go to your home page and switch back to English Change your machine timezone to UTC-0800 or at least really different than the one previously used Go to the calendar, and add a new event Make sure that the pop-up date selector correctly displays each month Month and days are correctly translated Correct month (February is not March, check that you'll never have two similar names while going from one month to another) Test 4 Go to your home page and switch back to English Change your user timezone to UTC-0800 or at least really different than the one previously used Go to the calendar, and add a new event Make sure that the pop-up date selector correctly displays each month Month and days are correctly translated Correct month (February is not March, check that you'll never have two similar names while going from one month to another) Test 5 Reward yourself with a candy!
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull Master Branch:

      Description

      After applying the patch from:
      http://tracker.moodle.org/browse/MDL-34708
      https://github.com/nebgor/moodle/commit/201816346877bde81b2673908efd2bb598fdccf5
      our date picker was working correctly until today.

      The date picker now does the following:
      August 2012 has the name of August 2012
      September 2012 has the name of October 2012
      October 2012 has the name of October 2012
      Nov 12 -> Dec 12
      Dec 12 -> Dec 12
      Jan 13 -> Jan 13
      Feb 12 -> Mar 13
      Mar 13 -> Mar 13
      Apr 13 -> May 13
      May 13 -> May 13
      Jun 13 -> Jul 13
      Jul 13 -> Jul 13
      Aug 13 -> Aug 13

      I tested this on latest code from the git repo, Moodle 2.3.1+ (Build: 20120831), and it has the issue as well. When test it was Aug 31, ~12:30pm MDT. I made sure the timezone data was up to date and tried different server default timezone settings. I wonder if it is a boundary condition problem because of the end of the month with 31 days. It looks like if a month has 31 days it displays the correct name and if it has less it displays the next month.

        Gliffy Diagrams

          Issue Links

            Activity

            mspall Michael Spall created issue -
            mspall Michael Spall made changes -
            Field Original Value New Value
            Link This issue has been marked as being related by MDL-34708 [ MDL-34708 ]
            mspall Michael Spall made changes -
            Link This issue has been marked as being related by MDL-34752 [ MDL-34752 ]
            mspall Michael Spall made changes -
            Priority Minor [ 4 ] Major [ 3 ]
            emmarichardson Emma Richardson made changes -
            Link This issue blocks MDL-35169 [ MDL-35169 ]
            emmarichardson Emma Richardson made changes -
            Link This issue blocks MDL-35169 [ MDL-35169 ]
            emmarichardson Emma Richardson made changes -
            Link This issue is duplicated by MDL-35169 [ MDL-35169 ]
            Hide
            smithrn Ryan Smith added a comment -

            Confirmed here...wow this date picker is a real mess. When I click forward a month it changes from Jan 2012 to March 2012.

            Show
            smithrn Ryan Smith added a comment - Confirmed here...wow this date picker is a real mess. When I click forward a month it changes from Jan 2012 to March 2012.
            Hide
            syxton Matthew Davidson added a comment -

            This is a regression bug from
            http://tracker.moodle.org/browse/MDL-34708

            I have submitted a fixed version according the instructions found here.
            https://bugs.php.net/bug.php?id=49115

            Show
            syxton Matthew Davidson added a comment - This is a regression bug from http://tracker.moodle.org/browse/MDL-34708 I have submitted a fixed version according the instructions found here. https://bugs.php.net/bug.php?id=49115
            Hide
            syxton Matthew Davidson added a comment -

            Here is the fixed code for formslib.php

            $config = array(array(
            'firstdayofweek' => get_string('firstdayofweek', 'langconfig'),
            'mon' => strftime('%a', strtotime("Monday")),
            'tue' => strftime('%a', strtotime("Tuesday")),
            'wed' => strftime('%a', strtotime("Wednesday")),
            'thu' => strftime('%a', strtotime("Thursday")),
            'fri' => strftime('%a', strtotime("Friday")),
            'sat' => strftime('%a', strtotime("Saturday")),
            'sun' => strftime('%a', strtotime("Sunday")),
            'january' => strftime('%B', strtotime("January 1")),
            'february' => strftime('%B', strtotime("February 1")),
            'march' => strftime('%B', strtotime("March 1")),
            'april' => strftime('%B', strtotime("April 1")),
            'may' => strftime('%B', strtotime("May 1")),
            'june' => strftime('%B', strtotime("June 1")),
            'july' => strftime('%B', strtotime("July 1")),
            'august' => strftime('%B', strtotime("August 1")),
            'september' => strftime('%B', strtotime("September 1")),
            'october' => strftime('%B', strtotime("October 1")),
            'november' => strftime('%B', strtotime("November 1")),
            'december' => strftime('%B', strtotime("December 1"))
            ));

            Show
            syxton Matthew Davidson added a comment - Here is the fixed code for formslib.php $config = array(array( 'firstdayofweek' => get_string('firstdayofweek', 'langconfig'), 'mon' => strftime('%a', strtotime("Monday")), 'tue' => strftime('%a', strtotime("Tuesday")), 'wed' => strftime('%a', strtotime("Wednesday")), 'thu' => strftime('%a', strtotime("Thursday")), 'fri' => strftime('%a', strtotime("Friday")), 'sat' => strftime('%a', strtotime("Saturday")), 'sun' => strftime('%a', strtotime("Sunday")), 'january' => strftime('%B', strtotime("January 1")), 'february' => strftime('%B', strtotime("February 1")), 'march' => strftime('%B', strtotime("March 1")), 'april' => strftime('%B', strtotime("April 1")), 'may' => strftime('%B', strtotime("May 1")), 'june' => strftime('%B', strtotime("June 1")), 'july' => strftime('%B', strtotime("July 1")), 'august' => strftime('%B', strtotime("August 1")), 'september' => strftime('%B', strtotime("September 1")), 'october' => strftime('%B', strtotime("October 1")), 'november' => strftime('%B', strtotime("November 1")), 'december' => strftime('%B', strtotime("December 1")) ));
            Hide
            mspall Michael Spall added a comment -

            We have tested this fix and it works. Thank you Matthew.

            Show
            mspall Michael Spall added a comment - We have tested this fix and it works. Thank you Matthew.
            Hide
            emerrill Eric Merrill added a comment -

            To give a little more description:

            When your current date is, say 31, and the system requests info on a month, if you just pass a month, it picks your current date, which in some months (those with less than your current date), it returns the next month (because the 30th of Feb, you really be March 2nd...). This patch specifies that you want the first day of the month in question.

            I've attached branch-ified patches.

            Show
            emerrill Eric Merrill added a comment - To give a little more description: When your current date is, say 31, and the system requests info on a month, if you just pass a month, it picks your current date, which in some months (those with less than your current date), it returns the next month (because the 30th of Feb, you really be March 2nd...). This patch specifies that you want the first day of the month in question. I've attached branch-ified patches.
            emerrill Eric Merrill made changes -
            Hide
            emerrill Eric Merrill added a comment - - edited

            In my tests, this patch caused the dates to show correctly through Dec 2020 (That's not to say it's wrong after that, that is as far as I checked!)

            Show
            emerrill Eric Merrill added a comment - - edited In my tests, this patch caused the dates to show correctly through Dec 2020 (That's not to say it's wrong after that, that is as far as I checked!)
            emerrill Eric Merrill made changes -
            Assignee moodle.com [ moodle.com ] Eric Merrill [ emerrill ]
            emerrill Eric Merrill made changes -
            Testing Instructions
            # In you server environment, make sure your day of month is the 29th or greater.
            # In a course, create an assignment, enable due date, and click on the day.
            # In the pop-up date selector, click to the right til Jan 2013.
            # Click forward, February 2013 should appear (with 28 days).
            # Click forward again, March 2013 should appear (with 31 days).
            emerrill Eric Merrill made changes -
            Status Open [ 1 ] Waiting for peer review [ 10012 ]
            Peer reviewer moodle.com
            emerrill Eric Merrill made changes -
            Link This issue is a regression caused by MDL-34708 [ MDL-34708 ]
            Hide
            emerrill Eric Merrill added a comment -

            Aparup,

            We wanted to bring you in on this ticket, since it was a regression caused by MDL-34708. If you could review the proposed patch and let us know what you think.

            Thanks

            Show
            emerrill Eric Merrill added a comment - Aparup, We wanted to bring you in on this ticket, since it was a regression caused by MDL-34708 . If you could review the proposed patch and let us know what you think. Thanks
            Hide
            nebgor Aparup Banerjee added a comment -

            Thanks Eric and David,
            MDL-34708 itself was a regression of MDL-31622 ( which clearly needed more work at that time )

            I've added Fred (who worked on MDL-31622) so that we can look across all these regressions and check it solves all.

            Show
            nebgor Aparup Banerjee added a comment - Thanks Eric and David, MDL-34708 itself was a regression of MDL-31622 ( which clearly needed more work at that time ) I've added Fred (who worked on MDL-31622 ) so that we can look across all these regressions and check it solves all.
            fred Frédéric Massart made changes -
            Peer reviewer moodle.com fred
            Testing Instructions
            # In you server environment, make sure your day of month is the 29th or greater.
            # In a course, create an assignment, enable due date, and click on the day.
            # In the pop-up date selector, click to the right til Jan 2013.
            # Click forward, February 2013 should appear (with 28 days).
            # Click forward again, March 2013 should appear (with 31 days).
            # In you server environment, make sure your day of month is the 29th or greater.
            # In a course, create an assignment, enable due date, and click on the day.
            # In the pop-up date selector, click to the right til Jan 2013.
            # Click forward, February 2013 should appear (with 28 days).
            # Click forward again, March 2013 should appear (with 31 days).
            fred Frédéric Massart made changes -
            Testing Instructions # In you server environment, make sure your day of month is the 29th or greater.
            # In a course, create an assignment, enable due date, and click on the day.
            # In the pop-up date selector, click to the right til Jan 2013.
            # Click forward, February 2013 should appear (with 28 days).
            # Click forward again, March 2013 should appear (with 31 days).
            *Test pre-requisites*

            - A few languages packs installed, including with non-enlish characters
            - Installing corresponding locales on your system `sudo locale-gen --no-archive ja_JP.UTF-8`
            - Set your machine date to the 31th of any month

            *Test 1*

            # Go to your home page and switch to English language pack
            # Go to the calendar, and add a new event
            # *Make sure* that the pop-up date selector correctly displays each month
            -- Correct month (February is not March, check that you'll never have two similar names while going from one month to another)

            *Test 2*

            # Go to your home page and switch to a funky language pack
            # Go to the calendar, and add a new event
            # *Make sure* that the pop-up date selector correctly displays each month
            -- Month and days are correctly translated
            -- Correct month (February is not March, check that you'll never have two similar names while going from one month to another)

            *Test 3*

            # Go to your home page and switch back to English
            # Change your machine timezone to UTC-0800 or at least really different than the one previously used
            # Go to the calendar, and add a new event
            # *Make sure* that the pop-up date selector correctly displays each month
            -- Month and days are correctly translated
            -- Correct month (February is not March, check that you'll never have two similar names while going from one month to another)

            *Test 4*

            # Go to your home page and switch back to English
            # Change your user timezone to UTC-0800 or at least really different than the one previously used
            # Go to the calendar, and add a new event
            # *Make sure* that the pop-up date selector correctly displays each month
            -- Month and days are correctly translated
            -- Correct month (February is not March, check that you'll never have two similar names while going from one month to another)

            *Test 5*

            # Reward yourself with a candy!
            Hide
            fred Frédéric Massart added a comment -

            Looks good to me. I am pushing for integration. I have amended the testing instructions not only to test this issue, but also to test the previous changes.

            Show
            fred Frédéric Massart added a comment - Looks good to me. I am pushing for integration. I have amended the testing instructions not only to test this issue, but also to test the previous changes.
            fred Frédéric Massart made changes -
            Status Waiting for peer review [ 10012 ] Waiting for integration review [ 10010 ]
            fred Frédéric Massart made changes -
            Link This issue has been marked as being related by MDL-34708 [ MDL-34708 ]
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

            TIA and ciao

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
            stronk7 Eloy Lafuente (stronk7) made changes -
            Currently in integration Yes [ 10041 ]
            stronk7 Eloy Lafuente (stronk7) made changes -
            Status Waiting for integration review [ 10010 ] Integration review in progress [ 10004 ]
            Integrator stronk7
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Integrated (22, 23 and master), thanks!

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Integrated (22, 23 and master), thanks!
            stronk7 Eloy Lafuente (stronk7) made changes -
            Status Integration review in progress [ 10004 ] Waiting for testing [ 10005 ]
            Affects Version/s 2.2.5 [ 12352 ]
            Affects Version/s 2.4 [ 12255 ]
            Fix Version/s 2.2.6 [ 12372 ]
            Fix Version/s 2.3.3 [ 12373 ]
            Fix Version/s STABLE backlog [ 10463 ]
            timb Tim Barker made changes -
            Tester phalacee
            salvetore Michael de Raadt made changes -
            Labels patch patch triaged
            phalacee Jason Fowler made changes -
            Status Waiting for testing [ 10005 ] Testing in progress [ 10011 ]
            Hide
            phalacee Jason Fowler added a comment -

            All fine, thanks for that Eric

            Show
            phalacee Jason Fowler added a comment - All fine, thanks for that Eric
            phalacee Jason Fowler made changes -
            Status Testing in progress [ 10011 ] Tested [ 10006 ]
            Hide
            k-yama Yamashita Kōichi added a comment -

            Since Moodle 2.3.2, "json_encode(): Invalid UTF-8 sequence in argument" occurs when editing quizzes etc., on Windows servers with some locales (e.g. Japanese). Changing the code in formslib like below fixes that.

            'mon' => userdate(strtotime("Monday"), '%a'), // 5th Jan 1970 at 12pm
            'january' => userdate(strtotime("January"), '%B'), // 1st Jan 1970 at 12pm

            Show
            k-yama Yamashita Kōichi added a comment - Since Moodle 2.3.2, "json_encode(): Invalid UTF-8 sequence in argument" occurs when editing quizzes etc., on Windows servers with some locales (e.g. Japanese). Changing the code in formslib like below fixes that. 'mon' => userdate(strtotime("Monday"), '%a'), // 5th Jan 1970 at 12pm 'january' => userdate(strtotime("January"), '%B'), // 1st Jan 1970 at 12pm
            Hide
            nebgor Aparup Banerjee added a comment - - edited

            Hi Yamashita , have you tested this against current integration.git code too?
            Edit: oh i see , should've read the code, thanks Yamashita

            Show
            nebgor Aparup Banerjee added a comment - - edited Hi Yamashita , have you tested this against current integration.git code too? Edit: oh i see , should've read the code, thanks Yamashita
            Hide
            fred Frédéric Massart added a comment -

            Hi Yamashita, apparently you do not have the latest version of formslib, would you please try out with the latest? On the other hand, could you provide more information about the browser you are using, operating system, the steps to replicate this error, and anything useful. Thanks!

            Show
            fred Frédéric Massart added a comment - Hi Yamashita, apparently you do not have the latest version of formslib, would you please try out with the latest? On the other hand, could you provide more information about the browser you are using, operating system, the steps to replicate this error, and anything useful. Thanks!
            Hide
            k-yama Yamashita Kōichi added a comment -

            Thanks for replies! I have just downloaded formslib.php from moodle.git and replaced with that included in 2.3.2 package but still it has problem.
            I get errors when editing a quiz (date selector is used for Timing > Open/Close the quiz), in some locales (en is OK but ja, fr, de all have errors).
            strftime can return results only in multibyte encoding on Windows so we need to convert back to UTF-8 for use in moodle. (userdate() in moodlelib.php does that.)

            My environment is: Moodle 2.3.2 (formslib.php replaced with latest), Windows 7, IIS 7.5, PHP 5.3.14 Zend Server, debug is set to DEVELOPER

            Show
            k-yama Yamashita Kōichi added a comment - Thanks for replies! I have just downloaded formslib.php from moodle.git and replaced with that included in 2.3.2 package but still it has problem. I get errors when editing a quiz (date selector is used for Timing > Open/Close the quiz), in some locales (en is OK but ja, fr, de all have errors). strftime can return results only in multibyte encoding on Windows so we need to convert back to UTF-8 for use in moodle. (userdate() in moodlelib.php does that.) My environment is: Moodle 2.3.2 (formslib.php replaced with latest), Windows 7, IIS 7.5, PHP 5.3.14 Zend Server, debug is set to DEVELOPER
            Hide
            nebgor Aparup Banerjee added a comment -

            Hi, the current patch is in http://git.moodle.org/gw/integration.git. This is where its being tested now, its not yet in moodle.git..

            Show
            nebgor Aparup Banerjee added a comment - Hi, the current patch is in http://git.moodle.org/gw/integration.git . This is where its being tested now, its not yet in moodle.git..
            Hide
            k-yama Yamashita Kōichi added a comment -

            json_encode error on Windows

            Show
            k-yama Yamashita Kōichi added a comment - json_encode error on Windows
            k-yama Yamashita Kōichi made changes -
            Attachment windows-unicode-error.png [ 29412 ]
            Hide
            k-yama Yamashita Kōichi added a comment -

            Aparup, thank you for pointing the correct repository. I checked out integration repository with git and run on my server. I see the problem is still present. Attached screenshot of quiz edit, shows stack trace of one error (the same errors occur about 18 times).

            Show
            k-yama Yamashita Kōichi added a comment - Aparup, thank you for pointing the correct repository. I checked out integration repository with git and run on my server. I see the problem is still present. Attached screenshot of quiz edit, shows stack trace of one error (the same errors occur about 18 times).
            Hide
            fred Frédéric Massart added a comment -

            Thanks Yamashita, I have created another issue to take care of this problem: MDL-35412.

            Show
            fred Frédéric Massart added a comment - Thanks Yamashita, I have created another issue to take care of this problem: MDL-35412 .
            fred Frédéric Massart made changes -
            Link This issue has a non-specific relationship to MDL-35412 [ MDL-35412 ]
            nebgor Aparup Banerjee made changes -
            Link This issue testing discovered MDL-35412 [ MDL-35412 ]
            fred Frédéric Massart made changes -
            Link This issue has a non-specific relationship to MDL-35412 [ MDL-35412 ]
            Hide
            k-yama Yamashita Kōichi added a comment -

            Thank you, Frédéric!

            Show
            k-yama Yamashita Kōichi added a comment - Thank you, Frédéric!
            Hide
            stronk7 Eloy Lafuente (stronk7) added a comment -

            Gutta cavat lapidem, non vi sed saepe cadendo - Ovidio

            This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads).

            Thanks!

            Show
            stronk7 Eloy Lafuente (stronk7) added a comment - Gutta cavat lapidem, non vi sed saepe cadendo - Ovidio This issue has been integrated upstream and is now available both via git and cvs (and in some hours, via mirrors and downloads). Thanks!
            stronk7 Eloy Lafuente (stronk7) made changes -
            Status Tested [ 10006 ] Closed [ 6 ]
            Resolution Fixed [ 1 ]
            Currently in integration Yes [ 10041 ]
            Integration date 14/Sep/12

              People

              • Votes:
                10 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Nov/12