From: Tim Düsterhus Date: Thu, 27 Apr 2023 14:21:17 +0000 (+0200) Subject: Unify the output format of `|date` and `|plainTime` with `{time}` X-Git-Tag: 6.0.0_Alpha_1~186^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=68db6844027a6045e74bc679ee88c7642e05de12;p=GitHub%2FWoltLab%2FWCF.git Unify the output format of `|date` and `|plainTime` with `{time}` see dbdc39a240f6e2e09550bab547e38d7aadba573a --- diff --git a/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php index 61d735d678..2747716f4a 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php @@ -3,6 +3,7 @@ namespace wcf\system\template\plugin; use wcf\system\template\TemplateEngine; +use wcf\system\WCF; use wcf\util\DateUtil; /** @@ -32,9 +33,18 @@ class DateModifierTemplatePlugin implements IModifierTemplatePlugin $dateTime = new \DateTimeImmutable('@' . $timestamp); } - return DateUtil::format( - $dateTime, - (!empty($tagArgs[1]) ? $tagArgs[1] : DateUtil::DATE_FORMAT) - ); + if (!empty($tagArgs[1])) { + return DateUtil::format( + $dateTime, + $tagArgs[1] + ); + } else { + return \IntlDateFormatter::create( + WCF::getLanguage()->getLocale(), + \IntlDateFormatter::LONG, + \IntlDateFormatter::NONE, + WCF::getUser()->getTimeZone() + )->format($dateTime); + } } } diff --git a/wcfsetup/install/files/lib/system/template/plugin/PlainTimeModifierTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/PlainTimeModifierTemplatePlugin.class.php index 4d1d2c1986..fb9ddcde5f 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/PlainTimeModifierTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/PlainTimeModifierTemplatePlugin.class.php @@ -4,7 +4,6 @@ namespace wcf\system\template\plugin; use wcf\system\template\TemplateEngine; use wcf\system\WCF; -use wcf\util\DateUtil; /** * Template modifier plugin which renders a \DateTimeInterface or @@ -33,14 +32,11 @@ class PlainTimeModifierTemplatePlugin implements IModifierTemplatePlugin $dateTime = new \DateTimeImmutable('@' . $timestamp); } - return \str_replace( - '%time%', - DateUtil::format($dateTime, DateUtil::TIME_FORMAT), - \str_replace( - '%date%', - DateUtil::format($dateTime, DateUtil::DATE_FORMAT), - WCF::getLanguage()->get('wcf.date.dateTimeFormat') - ) - ); + return \IntlDateFormatter::create( + WCF::getLanguage()->getLocale(), + \IntlDateFormatter::LONG, + \IntlDateFormatter::SHORT, + WCF::getUser()->getTimeZone() + )->format($dateTime); } }