. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Statistics\Repository; use Fisharebest\Webtrees\Carbon; 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 { /** * @return string */ public function serverDate(): string { $format = strtr(I18N::dateFormat(), ['%' => '']); $timezone = Site::getPreference('TIMEZONE', 'UTC'); return Carbon::now()->local()->timezone($timezone)->format($format); } /** * @return string */ public function serverTime(): string { $format = strtr(I18N::timeFormat(), ['%' => '']); $timezone = Site::getPreference('TIMEZONE', 'UTC'); return Carbon::now()->local()->timezone($timezone)->format($format); } /** * @return string */ public function serverTime24(): string { $timezone = Site::getPreference('TIMEZONE', 'UTC'); return Carbon::now()->local()->timezone($timezone)->format('G:i'); } /** * @return string */ public function serverTimezone(): string { $timezone = Site::getPreference('TIMEZONE', 'UTC'); return Carbon::now()->local()->timezone($timezone)->format('T'); } }