Moodle
  1. Moodle
  2. MDL-9729

Problems displaying correct weekdays

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8.1
    • Component/s: Calendar
    • Labels:
      None
    • Environment:
      I do not think that the OS is relevant (but is in on Ubuntu Edgy)
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE

      Description

      I ran across an issue with displaying the correct dates. The screenshot was taken on Monday, May 7th, 2007. In the Calendar settings I have monday set as the first day of the week (all other settings are standard).

      As you can see in the screenshot, the small calendar on the right displays the dates correctly. The big calendar does not!

        Gliffy Diagrams

        1. calendar.patch
          0.6 kB
          Eloy Lafuente (stronk7)
        1. calendar_problem.jpg
          47 kB

          Activity

          Hide
          Raymond Blenkiron added a comment -

          Concur - fresh install of 1.8 latest ('1.8 +' 08 May) on WAMP has day = date -1 whereas previous install ('1.7') has day in both calendar views the same.

          Show
          Raymond Blenkiron added a comment - Concur - fresh install of 1.8 latest ('1.8 +' 08 May) on WAMP has day = date -1 whereas previous install ('1.7') has day in both calendar views the same.
          Hide
          Richard Watkins added a comment - - edited

          In the function calendar_show_month_detailed (in calendar/view.php) that renders the large view it calculates the starting day using:
          $startwday = gmdate('w', $display->tstart); // $display->tstart is already GMT, so don't use date(): messes with server's TZ

          whereas in the function calendar_get_mini (in calendar/lib.php)
          $startwday = dayofweek(1, $m, $y);

          Changing gmdate for dayofweek seems to work but I am using GMT anyway so there may be issues for non-GMT servers?

          (btw, I've seen this bug on my Ubuntu server and on my Windows laptop)

          Show
          Richard Watkins added a comment - - edited In the function calendar_show_month_detailed (in calendar/view.php) that renders the large view it calculates the starting day using: $startwday = gmdate('w', $display->tstart); // $display->tstart is already GMT, so don't use date(): messes with server's TZ whereas in the function calendar_get_mini (in calendar/lib.php) $startwday = dayofweek(1, $m, $y); Changing gmdate for dayofweek seems to work but I am using GMT anyway so there may be issues for non-GMT servers? (btw, I've seen this bug on my Ubuntu server and on my Windows laptop)
          Hide
          Hans de Zwart added a comment -

          Well, my server is GMT+1...

          I have tried using dayofweek in calendar/view.php and that does indeed solve the problem! I wonder what happens around midnight...?

          Show
          Hans de Zwart added a comment - Well, my server is GMT+1... I have tried using dayofweek in calendar/view.php and that does indeed solve the problem! I wonder what happens around midnight...?
          Hide
          Derek Woolhead added a comment -

          Basically changes had been made to calendar/view.php calendar_show_month_detailed() function to take into account the users timezone. Unfortunately the start of week day calculation was not included in these changes and always used the gmt date function. The effect of this was the main calendar display could be one day out (one day earlier than expected) when local timezones were GMT+1 (i.e Daylight saving times). This fix only uses GMT time/date (gmmktime() and gmdate()) functions for GMT (start of week day in particular) otherwise it uses the mktime() and date() functions.

          Show
          Derek Woolhead added a comment - Basically changes had been made to calendar/view.php calendar_show_month_detailed() function to take into account the users timezone. Unfortunately the start of week day calculation was not included in these changes and always used the gmt date function. The effect of this was the main calendar display could be one day out (one day earlier than expected) when local timezones were GMT+1 (i.e Daylight saving times). This fix only uses GMT time/date (gmmktime() and gmdate()) functions for GMT (start of week day in particular) otherwise it uses the mktime() and date() functions.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Hi,

          just yesterday i received one message from a Spanish moodler pointing exactly to the same problem. After a quick look about how "mini-calendars" were working, I performed the patch above (locally).

          Not sure about what is the best solution, just pointing to an alternative... would be great to have the more robust in CVS (I'm off these weeks).

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Hi, just yesterday i received one message from a Spanish moodler pointing exactly to the same problem. After a quick look about how "mini-calendars" were working, I performed the patch above (locally). Not sure about what is the best solution, just pointing to an alternative... would be great to have the more robust in CVS (I'm off these weeks). Ciao

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: