You are here

function bat_check_dates_validity in Booking and Availability Management Tools for Drupal 7

Checks the logical validity of date values.

Parameters

DateTime $start_date: The start date.

DateTime $end_date: The end date.

Return value

array An array with error messages.

1 call to bat_check_dates_validity()
bat_form_start_end_dates_validate in ./bat.module
Validation callback that can be reused in all forms that need to validate dates.

File

./bat.module, line 703
Provides basic underlying functionality and configuration options used by all BAT modules.

Code

function bat_check_dates_validity(DateTime $start_date, DateTime $end_date) {
  $errors = array();

  // The end date must be greater or equal than start date.
  if ($end_date < $start_date) {
    $errors[] = t('End date must be on or after the start date.');
  }
  return $errors;
}