function facetapi_get_next_date_increment in Facet API 7
Same name and namespace in other branches
- 6.3 facetapi.date.inc \facetapi_get_next_date_increment()
- 7.2 facetapi.date.inc \facetapi_get_next_date_increment()
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.
File
- ./
facetapi.date.inc, line 248 - Date handling functions.
Code
function facetapi_get_next_date_increment($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 increment.
return facetapi_isodate(gmmktime($match[4], $match[5], $match[6], $match[2], $match[3], $match[1]));
}
return FALSE;
}