Unify the output format of `|date` and `|plainTime` with `{time}`
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 27 Apr 2023 14:21:17 +0000 (16:21 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 27 Apr 2023 14:22:00 +0000 (16:22 +0200)
see dbdc39a240f6e2e09550bab547e38d7aadba573a

wcfsetup/install/files/lib/system/template/plugin/DateModifierTemplatePlugin.class.php
wcfsetup/install/files/lib/system/template/plugin/PlainTimeModifierTemplatePlugin.class.php

index 61d735d6789f93fe85123fa583b5fb2a3f9919ca..2747716f4a09299e2d802392e01518d221d16eb2 100644 (file)
@@ -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);
+        }
     }
 }
index 4d1d2c19869d73376726044a4ba151fb8a7aa87d..fb9ddcde5f3b0ccb7ba2efd0dd74dcca1a0bf057 100644 (file)
@@ -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);
     }
 }