From: Cyperghost Date: Tue, 29 Oct 2024 13:16:06 +0000 (+0100) Subject: Use `\IntlDateFormatter` to format the date X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2c4ea2be5f3a566322391a0ff2f115b9e9701258;p=GitHub%2FWoltLab%2FWCF.git Use `\IntlDateFormatter` to format the date --- diff --git a/wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php b/wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php index 94f82cbbdf..384b22c509 100644 --- a/wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php +++ b/wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php @@ -4,7 +4,7 @@ namespace wcf\system\option\user; use wcf\data\user\option\UserOption; use wcf\data\user\User; -use wcf\util\DateUtil; +use wcf\system\WCF; /** * User option output implementation for for the output of a date input. @@ -15,12 +15,6 @@ use wcf\util\DateUtil; */ class DateUserOptionOutput implements IUserOptionOutput { - /** - * date format - * @var string - */ - protected $dateFormat = DateUtil::DATE_FORMAT; - /** * @inheritDoc */ @@ -32,11 +26,13 @@ class DateUserOptionOutput implements IUserOptionOutput $date = self::splitDate($value); - return DateUtil::format( - DateUtil::getDateTimeByTimestamp( - \gmmktime(12, 1, 1, $date['month'], $date['day'], $date['year']) - ), - $this->dateFormat + return \IntlDateFormatter::formatObject( + WCF::getUser()->getLocalDate(\gmmktime(12, 1, 1, $date['month'], $date['day'], $date['year'])), + [ + \IntlDateFormatter::LONG, + \IntlDateFormatter::NONE, + ], + WCF::getLanguage()->getLocale() ); } diff --git a/wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php index 7e4f8231e2..ee254d91d6 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php @@ -222,10 +222,15 @@ abstract class AbstractUserNotificationEvent extends DatabaseObjectDecorator imp $date->modify('-1 day'); self::$periods[$date->getTimestamp()] = WCF::getLanguage()->get('wcf.date.period.yesterday'); + $formatter = \IntlDateFormatter::create( + WCF::getLanguage()->getLocale(), + timezone: WCF::getUser()->getTimeZone(), + pattern: 'EEEE' + ); // 2-6 days back for ($i = 0; $i < 6; $i++) { $date->modify('-1 day'); - self::$periods[$date->getTimestamp()] = DateUtil::format($date, 'l'); + self::$periods[$date->getTimestamp()] = $formatter->format($date); } }