protected function validate_duedate($value) {

        // During update.
        if ($this->get('id')) {
            $before = $this->beforeupdate->get('duedate');

            // The value has not changed, then it's always OK.
            if ($before == $value) {
                return true;
            }
        }

        // During create and update, the date must be set in the future, or not set.
        if (!empty($value) && $value <= time() - 600) {
            // We cannot set the date in the past. But we allow for 10 minutes of margin so that
            // a user can set the due date to "now" without risking to hit a validation error.
            return new lang_string('errorcannotsetduedateinthepast', 'core_competency');
        }

        return true;
    }
protected function validate_duedate($value) {

        // During update.
        if ($this->get('id')) {
            $before = $this->beforeupdate->get('duedate');

            // The value has not changed, then it's always OK.
            if ($before == $value) {
                return true;
            }
        }

        // During create and update, the date must be set in the future, or not set.
        if (!empty($value) && $value <= time() - 600) {
            // We cannot set the date in the past. But we allow for 10 minutes of margin so that
            // a user can set the due date to "now" without risking to hit a validation error.
            return new lang_string('errorcannotsetduedateinthepast', 'core_competency');
        }

        return true;
    }
protected function validate_duedate ( $ value ) { // During update. if ( $ this -> get ( 'id' ) ) { $ before = $ this -> beforeupdate -> get ( 'duedate' ) ; // The value has not changed, then it's always OK. if ( $ before == $ value ) { return true ; } } // During create and update, the date must be set in the future, or not set. if ( ! empty ( $ value ) && $ value <= time ( ) - 600 ) { // We cannot set the date in the past. But we allow for 10 minutes of margin so that // a user can set the due date to "now" without risking to hit a validation error. return new lang_string ( 'errorcannotsetduedateinthepast' , 'core_competency' ) ; } return true ; }
Validate the due date.

The due date can always be changed, but when it is it must be:
- unset
- set in the future.

@param  int $value The due date.
@return bool|lang_string
Validate the due date .