You are here

function rooms_form_input_get_start_end_dates in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Given a form_state locate the start/end dates in the input array and instantiate and return DateTime objects.

9 calls to rooms_form_input_get_start_end_dates()
rooms_availability_update_status_form_submit in modules/rooms_availability/rooms_availability.module
Submit callback for rooms_availability_update_status_form form.
rooms_booking_availability_search_form_submit in modules/rooms_booking_manager/rooms_booking_manager.availability_search.inc
Submit callback for rooms_booking_availability_search_form form.
rooms_booking_availability_search_form_validate in modules/rooms_booking_manager/rooms_booking_manager.availability_search.inc
Validate callback form rooms_booking_availability_search_form form.
rooms_booking_edit_form in modules/rooms_booking/rooms_booking.admin.inc
Form callback: create or edit a booking.
rooms_booking_edit_form_validate in modules/rooms_booking/rooms_booking.admin.inc
Form API validate callback for the booking form.

... See full list

File

./rooms.module, line 955
Provides basic underlying functionality and configuration options used by all Rooms modules

Code

function rooms_form_input_get_start_end_dates($form_state) {

  // If form_state['values']['rooms_X_date'] is not set it is an empty array
  // hence the need to check and set values so that _constructor below will not
  // fail.
  if (is_array($form_state['values']['rooms_start_date']) || is_array($form_state['values']['rooms_end_date'])) {
    $form_state['values']['rooms_start_date'] = '';
    $form_state['values']['rooms_end_date'] = '';
  }
  $start = new DateTime($form_state['values']['rooms_start_date']);
  $end = new DateTime($form_state['values']['rooms_end_date']);
  return array(
    $start,
    $end,
  );
}