diff --git a/application/controllers/GraphController.php b/application/controllers/GraphController.php index 644c56a..0c3ea9f 100644 --- a/application/controllers/GraphController.php +++ b/application/controllers/GraphController.php @@ -2,13 +2,11 @@ namespace Icinga\Module\Graphite\Controllers; -use DateTimeZone; use Icinga\Exception\Http\HttpBadRequestException; use Icinga\Exception\Http\HttpNotFoundException; use Icinga\Module\Graphite\Graphing\GraphingTrait; use Icinga\Module\Graphite\Web\Controller\MonitoringAwareController; use Icinga\Module\Graphite\Web\Widget\Graphs; -use Icinga\Util\TimezoneDetect; use Icinga\Web\UrlParams; class GraphController extends MonitoringAwareController @@ -110,16 +108,12 @@ class GraphController extends MonitoringAwareController throw new HttpNotFoundException($this->translate('No such graph')); case 1: - $timezoneDetect = new TimezoneDetect(); $charts[0] ->setFrom($this->graphParams['start']) ->setUntil($this->graphParams['end']) ->setWidth($this->graphParams['width']) ->setHeight($this->graphParams['height']) ->setShowLegend((bool) $this->graphParams['legend']) - ->setTimeZone(new DateTimeZone( - $timezoneDetect->success() ? $timezoneDetect->getTimezoneName() : date_default_timezone_get() - )) ->serveImage($this->getResponse()); default: diff --git a/application/forms/TimeRangePicker/CustomForm.php b/application/forms/TimeRangePicker/CustomForm.php index baafe4f..a190b9d 100644 --- a/application/forms/TimeRangePicker/CustomForm.php +++ b/application/forms/TimeRangePicker/CustomForm.php @@ -6,7 +6,6 @@ use DateInterval; use DateTime; use DateTimeZone; use Icinga\Module\Graphite\Web\Form\Decorator\Proxy; -use Icinga\Util\TimezoneDetect; use Icinga\Web\Form; class CustomForm extends Form @@ -23,13 +22,6 @@ class CustomForm extends Form */ protected $timestamp = '/^(?:0|-?[1-9]\d*)$/'; - /** - * The time zone of all dates and times - * - * @var DateTimeZone - */ - protected $timeZone; - /** * Right now * @@ -164,7 +156,7 @@ class CustomForm extends Form list($date, $time) = explode( 'T', DateTime::createFromFormat('U', $timestamp) - ->setTimezone($this->getTimeZone()) + ->setTimezone(new DateTimeZone(date_default_timezone_get())) ->format($this->dateTimeFormat) ); @@ -209,8 +201,7 @@ class CustomForm extends Form $dateTime = DateTime::createFromFormat( $this->dateTimeFormat, ($date === '' ? $this->getNow()->format('Y-m-d') : $date) - . 'T' . ($time === '' ? $defaultTime : $time), - $this->getTimeZone() + . 'T' . ($time === '' ? $defaultTime : $time) ); if ($dateTime === false) { @@ -226,36 +217,6 @@ class CustomForm extends Form } } - /** - * Get {@link timeZone} - * - * @return DateTimeZone - */ - public function getTimeZone() - { - if ($this->timeZone === null) { - $timezoneDetect = new TimezoneDetect(); - $this->timeZone = new DateTimeZone( - $timezoneDetect->success() ? $timezoneDetect->getTimezoneName() : date_default_timezone_get() - ); - } - - return $this->timeZone; - } - - /** - * Set {@link timeZone} - * - * @param DateTimeZone $timeZone - * - * @return $this - */ - public function setTimeZone(DateTimeZone $timeZone) - { - $this->timeZone = $timeZone; - return $this; - } - /** * Get {@link now} * @@ -264,7 +225,7 @@ class CustomForm extends Form public function getNow() { if ($this->now === null) { - $this->now = (new DateTime())->setTimezone($this->getTimeZone()); + $this->now = new DateTime(); } return $this->now; diff --git a/library/Graphite/Graphing/Chart.php b/library/Graphite/Graphing/Chart.php index 1a00862..89d4548 100644 --- a/library/Graphite/Graphing/Chart.php +++ b/library/Graphite/Graphing/Chart.php @@ -2,7 +2,6 @@ namespace Icinga\Module\Graphite\Graphing; -use DateTimeZone; use Icinga\Module\Graphite\Util\MacroTemplate; use Icinga\Web\Response; use Icinga\Web\Url; @@ -66,13 +65,6 @@ class Chart */ protected $showLegend = true; - /** - * The chart's time zone - * - * @var DateTimeZone - */ - protected $timeZone; - /** * Constructor * @@ -118,7 +110,7 @@ class Chart 'width' => $this->width, 'height' => $this->height, 'hideLegend' => (string) ! $this->showLegend, - 'tz' => $this->timeZone->getName(), + 'tz' => date_default_timezone_get(), '_salt' => time() . '.000', 'vTitle' => 'Percent', 'lineMode' => 'connected', @@ -297,28 +289,4 @@ class Chart return $this; } - - /** - * Get time zone - * - * @return DateTimeZone - */ - public function getTimeZone() - { - return $this->timeZone; - } - - /** - * Set time zone - * - * @param DateTimeZone $timeZone - * - * @return $this - */ - public function setTimeZone(DateTimeZone $timeZone) - { - $this->timeZone = $timeZone; - - return $this; - } }