function rooms_form_values_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 values array and instantiate and return DateTime objects.
2 calls to rooms_form_values_get_start_end_dates()
- rooms_booking_edit_form in modules/
rooms_booking/ rooms_booking.admin.inc - Form callback: create or edit a booking.
- rooms_booking_manager_rooms_booking_edit_form_submit in modules/
rooms_booking_manager/ rooms_booking_manager.module - Submit handler for the 'rooms_booking_edit' form.
File
- ./
rooms.module, line 974 - Provides basic underlying functionality and configuration options used by all Rooms modules
Code
function rooms_form_values_get_start_end_dates($form_state) {
// As values dates has a format of year-month-day that is one of the default
// expected formats there is no need to explicit define format.
// http://www.php.net/manual/en/datetime.formats.date.php
$start_date = $form_state['values']['rooms_start_date'];
$end_date = $form_state['values']['rooms_end_date'];
// If the input format is numeric we assume that is a unixtime seconds format.
if (is_numeric($start_date) && is_numeric($end_date)) {
// The @ indicate DateTime that the format is unixtime.
$start_date = '@' . $start_date;
$end_date = '@' . $end_date;
}
$start = new DateTime($start_date);
$end = new DateTime($end_date);
return array(
$start,
$end,
);
}