function facetapi_gap_compare in Facet API 7
Same name and namespace in other branches
- 7.2 facetapi.date.inc \facetapi_gap_compare()
Compares two timestamp gaps.
Parameters
string $gap1:
string $gap2:
Return value
int Returns -1 if gap1 is less than gap2, 1 if gap1 is greater than gap2, and 0 if they are equal.
1 call to facetapi_gap_compare()
- facetapi_get_timestamp_gap in ./
facetapi.date.inc - Determines the best search gap to use for an arbitrary date range.
File
- ./
facetapi.date.inc, line 291 - Date handling functions.
Code
function facetapi_gap_compare($gap1, $gap2) {
$gap_numbers = array(
FACETAPI_DATE_YEAR => 6,
FACETAPI_DATE_MONTH => 5,
FACETAPI_DATE_DAY => 4,
FACETAPI_DATE_HOUR => 3,
FACETAPI_DATE_MINUTE => 2,
FACETAPI_DATE_SECOND => 1,
);
$gap1_num = isset($gap_numbers[$gap1]) ? $gap_numbers[$gap1] : 6;
$gap2_num = isset($gap_numbers[$gap2]) ? $gap_numbers[$gap2] : 6;
if ($gap1_num == $gap2_num) {
return 0;
}
else {
return $gap1_num < $gap2_num ? -1 : 1;
}
}