function availability_calendar_parse_iso_date in Availability Calendars 7.4
Same name and namespace in other branches
- 7.5 availability_calendar.inc \availability_calendar_parse_iso_date()
Parses a date string according to the ISO date format.
Parameters
string $date:
Return value
DateTime|false A DateTime object if the date string could successfully be parsed, false otherwise.
3 calls to availability_calendar_parse_iso_date()
- availability_calendar_handler_argument_availability::query in views/
availability_calendar_handler_argument_availability.inc - Inject a test for valid date range before the regular query. Override the parent query to be able to control the $group.
- availability_calendar_parse_entry_date in ./
availability_calendar.inc - Parses a date string according to the - possibly localized - 'Availability Calendar date entry' date type.
- availability_calendar_plugin_argument_validate_date_range::validate_argument in views/
availability_calendar_plugin_argument_validate_date_range.inc
File
- ./
availability_calendar.inc, line 238
Code
function availability_calendar_parse_iso_date($date) {
// Date API works in PHP5.2, DateTime::createFromFormat in PHP >= 5.3.
$result = module_exists('date_api') ? new DateObject($date, NULL, AC_ISODATE) : DateTime::createFromFormat(AC_ISODATE, $date);
if ($result instanceof DateObject && !empty($result->errors)) {
$result = FALSE;
}
if ($result instanceof DateTime) {
$result
->setTime(0, 0, 0);
}
return $result;
}