Use `\IntlDateFormatter` to format the date
authorCyperghost <olaf_schmitz_1@t-online.de>
Tue, 29 Oct 2024 13:16:06 +0000 (14:16 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Tue, 29 Oct 2024 13:21:40 +0000 (14:21 +0100)
wcfsetup/install/files/lib/system/option/user/DateUserOptionOutput.class.php
wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php

index 94f82cbbdff063e0fbc6a4ccd9cd67fc01a79c5f..384b22c50908a9ee7f21143f033868cc280c1689 100644 (file)
@@ -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()
         );
     }
 
index 7e4f8231e21b89f2032498747fee150653875a66..ee254d91d6a7d56bc636a9c1490cba053ae5234b 100644 (file)
@@ -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);
             }
         }