Page MenuHomePhabricator
Paste P61861

T363215-upstream
ActivePublic

Authored by Aklapper on May 3 2024, 4:46 PM.
Tags
None
Referenced Files
F50000547: T363215-upstream
May 3 2024, 4:46 PM
Subscribers
None
commit a42564511067cc3339818dbd790be06e367963b9 (HEAD -> master)
Author: Andre Klapper <aklapper@wikimedia.org>
Date: Fri May 3 18:42:38 2024 +0200
When creating a DateTime, do not localize the `A` format via `formatTime()` here. With translations of AM and PM in place, it blows up search for calendar events for translation letters not included in $translatable in https://we.phorge.it/source/arcanist/browse/master/src/internationalization/PhutilTranslator.php$222
diff --git a/src/view/form/control/AphrontFormDateControlValue.php b/src/view/form/control/AphrontFormDateControlValue.php
index 873ad44fe4..b55e2616c3 100644
--- a/src/view/form/control/AphrontFormDateControlValue.php
+++ b/src/view/form/control/AphrontFormDateControlValue.php
@@ -97,7 +97,8 @@ final class AphrontFormDateControlValue extends Phobject {
return $value;
}
- $readable = $value->formatTime($epoch, 'Y!m!d!g:i A');
+ $dt = new DateTime("@$epoch");
+ $readable = $dt->format('Y!m!d!g:i A');
$readable = explode('!', $readable, 4);
$year = $readable[0];
diff --git a/src/view/viewutils.php b/src/view/viewutils.php
index 956f6ca2c2..96f555bcd3 100644
--- a/src/view/viewutils.php
+++ b/src/view/viewutils.php
@@ -132,8 +132,8 @@ function phabricator_format_local_time($epoch, $user, $format) {
try {
$date = new DateTime('@'.$epoch);
} catch (Exception $ex) {
- // NOTE: DateTime throws an empty exception if the format is invalid,
- // just replace it with a useful one.
+ // NOTE: Before PHP 8.3, DateTime throws an empty exception if the format
+ // is invalid, just replace it with a useful one.
throw new Exception(
pht("Construction of a DateTime() with epoch '%s' ".
"raised an exception.", $epoch));