original_string: public function checkdate($defaultonow = true) {
          if (!checkdate($this->month, $this->day, $this->year)) {
              if ($defaultonow) {
                  $now = usergetdate(time());
                  $this->day = intval($now['mday']);
                  $this->month = intval($now['mon']);
                  $this->year = intval($now['year']);
                  return true;
              } else {
                  throw new moodle_exception('invaliddate');
              }
          }
          return true;
      }
code: public function checkdate($defaultonow = true) {
          if (!checkdate($this->month, $this->day, $this->year)) {
              if ($defaultonow) {
                  $now = usergetdate(time());
                  $this->day = intval($now['mday']);
                  $this->month = intval($now['mon']);
                  $this->year = intval($now['year']);
                  return true;
              } else {
                  throw new moodle_exception('invaliddate');
              }
          }
          return true;
      }
code_tokens: public function checkdate ( $ defaultonow = true ) { if ( ! checkdate ( $ this -> month , $ this -> day , $ this -> year ) ) { if ( $ defaultonow ) { $ now = usergetdate ( time ( ) ) ; $ this -> day = intval ( $ now [ 'mday' ] ) ; $ this -> month = intval ( $ now [ 'mon' ] ) ; $ this -> year = intval ( $ now [ 'year' ] ) ; return true ; } else { throw new moodle_exception ( 'invaliddate' ) ; } } return true ; }
docstring: Ensures the date for the calendar is correct and either sets it to now
  or throws a moodle_exception if not
  
  @param bool $defaultonow use current time
  @throws moodle_exception
  @return bool validation of checkdate
docstring_tokens: Ensures the date for the calendar is correct and either sets it to now or throws a moodle_exception if not