views_database_connector_handler_filter_datetime.inc in Views Database Connector 7
File
views/views_database_connector_handler_filter_datetime.inc
View source
<?php
class views_database_connector_handler_filter_datetime extends views_handler_filter_date {
function op_simple($field) {
$value = intval(strtotime($this->value['value'], 0));
if (!empty($this->value['type']) && $this->value['type'] == 'offset') {
$value = time() + sprintf('%+d', $value);
}
$value = $this
->format_date($value);
$this->query
->add_where($this->options['group'], $field, $value, $this->operator);
}
function op_between($field) {
if ($this->operator == 'between') {
$a = intval(strtotime($this->value['min'], 0));
$b = intval(strtotime($this->value['max'], 0));
}
else {
$a = intval(strtotime($this->value['max'], 0));
$b = intval(strtotime($this->value['min'], 0));
$this->query
->set_where_group('OR', $this->options['group']);
}
if ($this->value['type'] == 'offset') {
$now = time();
$a = $now + sprintf('%+d', $a);
$b = $now + sprintf('%+d', $b);
}
$a = $this
->format_date($a);
$b = $this
->format_date($b);
$this->query
->add_where($this->options['group'], $field, $a, '>=');
$this->query
->add_where($this->options['group'], $field, $b, '<=');
}
function format_date($unixtime) {
return date("Y-m-d H:i:s", $unixtime);
}
}