. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Statistics\Repository; use Carbon\Carbon; use Fisharebest\Webtrees\Functions\FunctionsDate; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Site; use Fisharebest\Webtrees\Statistics\Repository\Interfaces\ServerRepositoryInterface; /** * A repository providing methods for server related statistics. */ class ServerRepository implements ServerRepositoryInterface { /** * @inheritDoc */ public function serverDate(): string { $format = strtr(I18N::dateFormat(), ['%' => '']); $timezone = Site::getPreference('TIMEZONE', 'UTC'); return I18N::localTime(Carbon::now(), $format, $timezone); } /** * @inheritDoc */ public function serverTime(): string { $format = strtr(I18N::timeFormat(), ['%' => '']); $timezone = Site::getPreference('TIMEZONE', 'UTC'); return I18N::localTime(Carbon::now(), $format, $timezone); } /** * @inheritDoc */ public function serverTime24(): string { $timezone = Site::getPreference('TIMEZONE', 'UTC'); return I18N::localTime(Carbon::now(), 'G:i', $timezone); } /** * @inheritDoc */ public function serverTimezone(): string { $timezone = Site::getPreference('TIMEZONE', 'UTC'); return I18N::localTime(Carbon::now(), 'T', $timezone); } }