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;
    }
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;
    }
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 ; }
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
Ensures the date for the calendar is correct and either sets it to now or throws a moodle_exception if not