@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Don't try to translate date elements used internally in AphrontFormDateControlValue

Summary: Fixes T15811. Alternative to D25618

Test Plan: Observe that the lengthy steps to reproduce in T15811 no longer reproduce. Observe that translated date strings (e.p.p.) still appear in most parts of the interface

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: avivey, aklapper, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15811

Differential Revision: https://we.phorge.it/D25861

Pppery 76bdeb29 0592aa4b

+35 -16
+1
src/__phutil_library_map__.php
··· 5961 5961 'phid_get_subtype' => 'applications/phid/utils.php', 5962 5962 'phid_get_type' => 'applications/phid/utils.php', 5963 5963 'phid_group_by_type' => 'applications/phid/utils.php', 5964 + 'phorge_localize_time' => 'view/viewutils.php', 5964 5965 'phutil_escape_html' => 'infrastructure/markup/render.php', 5965 5966 'phutil_escape_html_newlines' => 'infrastructure/markup/render.php', 5966 5967 'phutil_implode_html' => 'infrastructure/markup/render.php',
+8 -4
src/view/form/control/AphrontFormDateControlValue.php
··· 166 166 } 167 167 168 168 private function formatTime($epoch, $format) { 169 - return phabricator_format_local_time( 170 - $epoch, 171 - $this->viewer, 172 - $format); 169 + $date = phorge_localize_time($epoch, $this->viewer); 170 + if (!$date) { 171 + return ''; 172 + } 173 + // Call DateTime->format directly (bypassing PhutilTranslator) 174 + // so that getFormattedDateFromParts below can decode the parts 175 + // back into a DateTime 176 + return $date->format($format); 173 177 } 174 178 175 179 public function getEpoch() {
+26 -12
src/view/viewutils.php
··· 99 99 return pht('%s (%s)', $datetime, $timezone); 100 100 } 101 101 102 + 102 103 /** 103 - * This function does not usually need to be called directly. Instead, call 104 - * @{function:phabricator_date}, @{function:phabricator_time}, or 105 - * @{function:phabricator_datetime}. 106 - * 104 + * Applies the user's timezone preferences to convert the give 105 + * epoch (number of seconds since January 1, 1970) to a DateTime object 107 106 * @param int $epoch Unix epoch timestamp. 108 107 * @param PhabricatorUser $user User viewing the timestamp. 109 - * @param string $format Date format, as per DateTime class. 110 - * @return string Formatted, local date/time. 108 + * @return ?DateTime 111 109 */ 112 - function phabricator_format_local_time($epoch, $user, $format) { 110 + function phorge_localize_time($epoch, $user) { 113 111 if (!$epoch) { 114 112 // If we're missing date information for something, the DateTime class will 115 - // throw an exception when we try to construct an object. Since this is a 116 - // display function, just return an empty string. 117 - return ''; 113 + // throw an exception when we try to construct an object. 114 + return null; 118 115 } 119 - 120 - $user_zone = $user->getTimezoneIdentifier(); 116 + $user_zone = $user->getTimezoneIdentifier(); 121 117 122 118 static $zones = array(); 123 119 if (empty($zones[$user_zone])) { ··· 140 136 } 141 137 142 138 $date->setTimezone($zone); 139 + return $date; 140 + } 143 141 142 + /** 143 + * This function does not usually need to be called directly. Instead, call 144 + * @{function:phabricator_date}, @{function:phabricator_time}, or 145 + * @{function:phabricator_datetime}. 146 + * 147 + 148 + * @param string $format Date format, as per DateTime class. 149 + * @return string Formatted, local date/time. 150 + */ 151 + function phabricator_format_local_time($epoch, $user, $format) { 152 + $date = phorge_localize_time($epoch, $user); 153 + if (!$date) { 154 + // If we're missing date information for something, display that as 155 + // an empty string 156 + return ''; 157 + } 144 158 return PhutilTranslator::getInstance()->translateDate($format, $date); 145 159 }