From 68db6844027a6045e74bc679ee88c7642e05de12 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 27 Apr 2023 16:21:17 +0200 Subject: [PATCH] Unify the output format of `|date` and `|plainTime` with `{time}` see dbdc39a240f6e2e09550bab547e38d7aadba573a --- .../DateModifierTemplatePlugin.class.php | 18 ++++++++++++++---- .../PlainTimeModifierTemplatePlugin.class.php | 16 ++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) 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); } } -- 2.20.1