diff --git a/app/Repositories/Metric/MySqlRepository.php b/app/Repositories/Metric/MySqlRepository.php index ba3a7a1f..cbb93506 100644 --- a/app/Repositories/Metric/MySqlRepository.php +++ b/app/Repositories/Metric/MySqlRepository.php @@ -47,8 +47,7 @@ class MySqlRepository implements MetricInterface */ public function getPointsLastHour(Metric $metric, $hour, $minute) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('PT'.$hour.'H'))->sub(new DateInterval('PT'.$minute.'M')); + $dateTime = (new Date())->sub(new DateInterval('PT'.$hour.'H'))->sub(new DateInterval('PT'.$minute.'M')); $timeInterval = $dateTime->format('YmdHi'); $points = $metric->points() @@ -78,8 +77,7 @@ class MySqlRepository implements MetricInterface */ public function getPointsByHour(Metric $metric, $hour) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('PT'.$hour.'H')); + $dateTime = (new Date())->sub(new DateInterval('PT'.$hour.'H')); $hourInterval = $dateTime->format('YmdH'); $points = $metric->points() @@ -108,8 +106,7 @@ class MySqlRepository implements MetricInterface */ public function getPointsForDayInWeek(Metric $metric, $day) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('P'.$day.'D')); + $dateTime = (new Date())->sub(new DateInterval('P'.$day.'D')); $points = $metric->points() ->whereRaw('created_at BETWEEN DATE_SUB(created_at, INTERVAL 1 WEEK) AND NOW()') diff --git a/app/Repositories/Metric/PgSqlRepository.php b/app/Repositories/Metric/PgSqlRepository.php index 3000c8e8..e08f3af1 100644 --- a/app/Repositories/Metric/PgSqlRepository.php +++ b/app/Repositories/Metric/PgSqlRepository.php @@ -13,29 +13,11 @@ namespace CachetHQ\Cachet\Repositories\Metric; use CachetHQ\Cachet\Models\Metric; use DateInterval; -use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\DB; use Jenssegers\Date\Date; class PgSqlRepository implements MetricInterface { - /** - * The timezone the status page is showing in. - * - * @var string - */ - protected $dateTimeZone; - - /** - * Creates a new instance of the metric repository. - * - * @return void - */ - public function __construct() - { - $this->dateTimeZone = Config::get('cachet.timezone'); - } - /** * Returns metrics for the last hour. * @@ -47,8 +29,7 @@ class PgSqlRepository implements MetricInterface */ public function getPointsLastHour(Metric $metric, $hour, $minute) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('PT'.$hour.'H'))->sub(new DateInterval('PT'.$minute.'M')); + $dateTime = (new Date())->sub(new DateInterval('PT'.$hour.'H'))->sub(new DateInterval('PT'.$minute.'M')); $hourInterval = $dateTime->format('YmdHi'); // Default metrics calculations. @@ -88,8 +69,7 @@ class PgSqlRepository implements MetricInterface */ public function getPointsByHour(Metric $metric, $hour) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('PT'.$hour.'H')); + $dateTime = (new Date())->sub(new DateInterval('PT'.$hour.'H')); $hourInterval = $dateTime->format('YmdH'); // Default metrics calculations. @@ -128,8 +108,7 @@ class PgSqlRepository implements MetricInterface */ public function getPointsForDayInWeek(Metric $metric, $day) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('P'.$day.'D')); + $dateTime = (new Date())->sub(new DateInterval('P'.$day.'D')); $points = $metric->points() ->whereRaw('created_at BETWEEN (created_at - interval \'1 week\') AND now()') diff --git a/app/Repositories/Metric/SqliteRepository.php b/app/Repositories/Metric/SqliteRepository.php index c5d9ab73..112aaab3 100644 --- a/app/Repositories/Metric/SqliteRepository.php +++ b/app/Repositories/Metric/SqliteRepository.php @@ -13,29 +13,11 @@ namespace CachetHQ\Cachet\Repositories\Metric; use CachetHQ\Cachet\Models\Metric; use DateInterval; -use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\DB; use Jenssegers\Date\Date; class SqliteRepository implements MetricInterface { - /** - * The timezone the status page is showing in. - * - * @var string - */ - protected $dateTimeZone; - - /** - * Creates a new instance of the metric repository. - * - * @return void - */ - public function __construct() - { - $this->dateTimeZone = Config::get('cachet.timezone'); - } - /** * Returns metrics for the last hour. * @@ -47,8 +29,7 @@ class SqliteRepository implements MetricInterface */ public function getPointsLastHour(Metric $metric, $hour, $minute) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('PT'.$hour.'H'))->sub(new DateInterval('PT'.$minute.'M')); + $dateTime = (new Date())->sub(new DateInterval('PT'.$hour.'H'))->sub(new DateInterval('PT'.$minute.'M')); $hourInterval = $dateTime->format('YmdHi'); $points = $metric->points() @@ -78,8 +59,7 @@ class SqliteRepository implements MetricInterface */ public function getPointsByHour(Metric $metric, $hour) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('PT'.$hour.'H')); + $dateTime = (new Date())->sub(new DateInterval('PT'.$hour.'H')); $hourInterval = $dateTime->format('YmdH'); $points = $metric->points() @@ -108,8 +88,7 @@ class SqliteRepository implements MetricInterface */ public function getPointsForDayInWeek(Metric $metric, $day) { - $dateTime = (new Date())->setTimezone($this->dateTimeZone); - $dateTime->sub(new DateInterval('P'.$day.'D')); + $dateTime = (new Date())->sub(new DateInterval('P'.$day.'D')); $points = $metric->points() ->whereRaw('created_at > date("now", "-7 day")')