respect users timezone in statistic widgets (#1207)

This commit is contained in:
Kevin Papst
2019-10-31 00:17:31 +01:00
committed by GitHub
parent 4331a7c9f4
commit 8eec97deb5
5 changed files with 16 additions and 23 deletions

View File

@@ -35,29 +35,19 @@ class TimezoneSubscriber implements EventSubscriberInterface
}
public function setTimezone(RequestEvent $event)
{
if (!$this->canHandleEvent()) {
return;
}
/** @var User $user */
$user = $this->storage->getToken()->getUser();
$timezone = $user->getPreferenceValue('timezone', date_default_timezone_get());
date_default_timezone_set($timezone);
}
protected function canHandleEvent(): bool
{
if (null === $this->storage->getToken()) {
return false;
return;
}
$user = $this->storage->getToken()->getUser();
if (null === $user) {
return false;
return;
}
return ($user instanceof User);
if ($user instanceof User) {
date_default_timezone_set($user->getTimezone());
}
}
}