function facetapi_next_date_increment_get in Facet API 6
Returns the next increment from the given ISO date and gap. This function is useful for getting the upper limit of a date range from the given start date.
Parameters
$date: A string containing the date as an ISO date string.
$gap: A string containing the gap, see FACETAPI_DATE_* constants for valid values, defaults to YEAR.
Return value
A string containing the date, FALSE if the passed date could not be parsed.
1 call to facetapi_next_date_increment_get()
- FacetapiLuceneapiAdapter::fetchDate in contrib/
facetapi_luceneapi/ facetapi_luceneapi.adapter.inc - Fetches data from facets that filter results by date ranges.
File
- ./
facetapi.module, line 1265 - An abstracted facet API that can be used by various search backens.
Code
function facetapi_next_date_increment_get($date, $gap) {
if (preg_match(FACETAPI_REGEX_DATE, $date, $match)) {
// Increments the timestamp.
switch ($gap) {
case FACETAPI_DATE_MONTH:
$match[2] += 1;
break;
case FACETAPI_DATE_DAY:
$match[3] += 1;
break;
case FACETAPI_DATE_HOUR:
$match[4] += 1;
break;
case FACETAPI_DATE_MINUTE:
$match[5] += 1;
break;
case FACETAPI_DATE_SECOND:
$match[6] += 1;
break;
default:
$match[1] += 1;
break;
}
// Gets the next incremenet.
return facetapi_isodate(gmmktime($match[4], $match[5], $match[6], $match[2], $match[3], $match[1]));
}
return FALSE;
}