protected static function SearchApiElasticsearchConnector::getDateGap in Elasticsearch Connector 7
Same name and namespace in other branches
- 7.5 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::getDateGap()
- 7.2 modules/elasticsearch_connector_search_api/service.inc \SearchApiElasticsearchConnector::getDateGap()
Helper function. Return date gap from two dates or timestamps.
See also
1 call to SearchApiElasticsearchConnector::getDateGap()
- SearchApiElasticsearchConnector::getDateGranularity in modules/
elasticsearch_connector_search_api/ service.inc - Helper function to return date gap.
File
- modules/
elasticsearch_connector_search_api/ service.inc, line 1068 - Provides a Elasticsearch-based service class for the Search API using Elasticsearch Connector module.
Class
- SearchApiElasticsearchConnector
- Search service class.
Code
protected static function getDateGap($min, $max, $timestamp = TRUE) {
if ($timestamp !== TRUE) {
$min = strtotime($min);
$max = strtotime($max);
}
if (empty($min) || empty($max)) {
return 'DAY';
}
$diff = $max - $min;
switch (TRUE) {
case $diff > 86400 * 365:
return 'NONE';
case $diff > 86400 * gmdate('t', $min):
return 'YEAR';
case $diff > 86400:
return 'MONTH';
default:
return 'DAY';
}
}