diff --git a/src/InfluxDB/Query/Builder.php b/src/InfluxDB/Query/Builder.php index b91d8f0..0deb85b 100644 --- a/src/InfluxDB/Query/Builder.php +++ b/src/InfluxDB/Query/Builder.php @@ -80,6 +80,11 @@ class Builder */ protected $orderBy; + /** + * @var string + */ + protected $tz; + /** * @param Database $db */ @@ -267,6 +272,20 @@ public function offset($count) return $this; } + /** + * Set the timezone + * + * @param string $timezone + * + * @return $this + */ + public function tz($timezone) + { + $this->tz = $timezone; + + return $this; + } + /** * Add retention policy to query * @@ -295,9 +314,9 @@ public function getQuery() * @return ResultSet * @throws \Exception */ - public function getResultSet() + public function getResultSet($params=[]) { - return $this->db->query($this->parseQuery()); + return $this->db->query($this->parseQuery(), $params); } /** @@ -345,6 +364,14 @@ protected function parseQuery() $query .= $this->offsetClause; } + if (isset($this->tz)) { + //also add support for timezone offset + $tz = is_numeric(trim($this->tz,0))? + timezone_name_from_abbr('',$this->tz*3600,0): + $this->tz; + $query .= " tz('".$tz."')"; + } + return $query; } }