Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-26753 DST issues
  3. MDL-27577

/lib/moodlelib.php functions userdate() and make_timestamp() were applying dst_offset for numeric timezones, i.e. 0 (UTC)

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.9.12, 2.0
    • Fix Version/s: 1.9.13, 2.0.4
    • Component/s: Libraries
    • Labels:
    • Testing Instructions:
      Hide

      1. Login as admin
      2. Update timezone (Site administration -> location -> update timezone)
      3. Run testmoodlelib.php simpletest.

      Instructions to run testmoodlelib.php simpletest
      On Moodle 2.xx
      1. Navigate to unit test (Development -> unit test)
      2. enter "lib/simpletest/testmoodlelib.php" in textbox.
      3. click "Run test"

      On Moodle 1.9x
      1. Navigate to unit test (Reports -> unit test)
      2. enter "lib/simpletest/testmoodlelib.php" in textbox.
      3. click "Run test"

      Show
      1. Login as admin 2. Update timezone (Site administration -> location -> update timezone) 3. Run testmoodlelib.php simpletest. Instructions to run testmoodlelib.php simpletest On Moodle 2.xx 1. Navigate to unit test (Development -> unit test) 2. enter "lib/simpletest/testmoodlelib.php" in textbox. 3. click "Run test" On Moodle 1.9x 1. Navigate to unit test (Reports -> unit test) 2. enter "lib/simpletest/testmoodlelib.php" in textbox. 3. click "Run test"
    • Affected Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE, MOODLE_20_STABLE
    • Pull Master Branch:
      wip-mdl-27577-master

      Description

      /lib/moodlelib.php functions userdate() and make_timestamp() were applying dst_offset for numeric timezones, i.e. 0 (UTC)
      Our remedy:

      function make_timestamp($year, $month=1, $day=1, $hour=0, $minute=0, $second=0, $timezone=99, $applydst=true) {
       
          $passedtimezone = $timezone;
          $strtimezone = NULL;
          if (!is_numeric($timezone)) {
              $strtimezone = $timezone;
          }
       
          $timezone = get_user_timezone_offset($timezone);
       
          if (abs($timezone) > 13) {
              $time = mktime((int)$hour, (int)$minute, (int)$second, (int)$month, (int)$day, (int)$year);
          } else {
              $time = gmmktime((int)$hour, (int)$minute, (int)$second, (int)$month, (int)$day, (int)$year);
              $time = usertime($time, $timezone);
              if ($applydst && ($passedtimezone == 99 || !is_numeric($passedtimezone))) {
                  $time -= dst_offset_on($time, $strtimezone);
              }
          }
       
          return $time;
       
      }
       
      in userdate(): 
      ... // added if clause
          if ($timezone == 99 || !is_numeric($timezone)) {
              $date += dst_offset_on($date, $strtimezone);
          }
      ...

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    1/Aug/11