diff --git a/scheduler_handler_field_scheduler_countdown.inc b/scheduler_handler_field_scheduler_countdown.inc index 406ec0c..ddce21e 100644 --- a/scheduler_handler_field_scheduler_countdown.inc +++ b/scheduler_handler_field_scheduler_countdown.inc @@ -57,14 +57,15 @@ class scheduler_handler_field_scheduler_countdown extends views_handler_field { /** * Add the new timestamp_field into the SQL query. * - * It will be calculated as publish_on - unix_timestamp() so the result is - * the number of seconds from now until the event. + * It will be calculated as publish_on - time() so the result + * is the number of seconds from now until the event. */ function query() { $this->ensure_my_table(); $this->node_table = $this->query->ensure_table('node', $this->relationship); $time_field = $this->definition['timestamp_field']; - $this->field_alias = $this->query->add_field(NULL, 'IF(' . $time_field . ' AND ' . $time_field . ' > UNIX_TIMESTAMP(), ' . $time_field . ' - UNIX_TIMESTAMP(), NULL)', $this->table_alias . '_' . $this->field); + $now = time(); + $this->field_alias = $this->query->add_field(NULL, 'CASE WHEN (' . $time_field . ' IS NOT NULL AND ' . $time_field . ' > ' . $now . ') THEN (' . $time_field . ' - ' . $now . ') ELSE NULL END', $this->table_alias . '_' . $this->field); } /**