protected function Date::opBetween in CiviCRM Entity 8.3
Filters by operator between.
Parameters
object $field: The views field.
Overrides Date::opBetween
File
- src/
Plugin/ views/ filter/ Date.php, line 49
Class
- Date
- An "In" handler to include CiviCRM API.
Namespace
Drupal\civicrm_entity\Plugin\views\filterCode
protected function opBetween($field) {
$a = intval(strtotime($this->value['min'], 0));
$b = intval(strtotime($this->value['max'], 0));
if ($this->value['type'] == 'offset') {
$now = time();
$a = $now + sprintf('%+d', $a);
$b = $now + sprintf('%+d', $b);
}
$a = DateTimePlus::createFromTimestamp($a);
$a = $this->dateFormatter
->format($a
->getTimestamp(), 'custom', $this->dateFormat);
$a = $this
->getFieldDateFormat("'" . $a . "'");
$b = DateTimePlus::createFromTimestamp($b);
$b = $this->dateFormatter
->format($b
->getTimestamp(), 'custom', $this->dateFormat);
$b = $this
->getFieldDateFormat("'" . $b . "'");
$operator = strtoupper($this->operator);
$field = $this
->getFieldDateFormat($field);
$this->query
->addWhereExpression($this->options['group'], "{$field} {$operator} {$a} AND {$b}");
}