function facetapi_date_gap_get in Facet API 6
Converts ISO date strings to Unix timestamps, passes values to the facetapi_timestamp_gap_get() function to calculate the gap.
Parameters
$start_date: A string containing the start date as an ISO date string.
$end_date: A string containing the end date as an ISO date string.
Return value
A string containing the gap, see FACETAPI_DATE_* constants for valid values. Returns FALSE of either of the dates cannot be converted to a timestamp.
See also
3 calls to facetapi_date_gap_get()
- FacetapiLuceneapiAdapter::fetchDate in contrib/
facetapi_luceneapi/ facetapi_luceneapi.adapter.inc - Fetches data from facets that filter results by date ranges.
- facetapi_apachesolr_date_range in contrib/
facetapi_apachesolr/ facetapi_apachesolr.module - Gets the range of dates we are using.
- facetapi_callback_date_map in ./
facetapi.callbacks.inc - Converts date ranges to human readable dates.
File
- ./
facetapi.module, line 1186 - An abstracted facet API that can be used by various search backens.
Code
function facetapi_date_gap_get($start_date, $end_date) {
$range = array(
strtotime($start_date),
strtotime($end_date),
);
// NOTE: Previous to PHP 5.1.0, this strtotime() returns -1 on failure.
if (!in_array(FALSE, $range, TRUE) && !in_array(-1, $range)) {
return facetapi_timestamp_gap_get($range[0], $range[1]);
}
return FALSE;
}