Page MenuHomePhorge

D25861.1736611762.diff
No OneTemporary

D25861.1736611762.diff

diff --git a/src/view/form/control/AphrontFormDateControlValue.php b/src/view/form/control/AphrontFormDateControlValue.php
--- a/src/view/form/control/AphrontFormDateControlValue.php
+++ b/src/view/form/control/AphrontFormDateControlValue.php
@@ -169,7 +169,8 @@
return phabricator_format_local_time(
$epoch,
$this->viewer,
- $format);
+ $format,
+ false); // Don't translate the date, to allow us to reparse it later
}
public function getEpoch() {
diff --git a/src/view/viewutils.php b/src/view/viewutils.php
--- a/src/view/viewutils.php
+++ b/src/view/viewutils.php
@@ -107,9 +107,14 @@
* @param int $epoch Unix epoch timestamp.
* @param PhabricatorUser $user User viewing the timestamp.
* @param string $format Date format, as per DateTime class.
+ * @param bool $translate (optional) Whether to translate individual date
+ * elements. If set to false, will leave them in English, but
+ * still apply the user's timezone preferences.
* @return string Formatted, local date/time.
*/
-function phabricator_format_local_time($epoch, $user, $format) {
+function phabricator_format_local_time(
+ $epoch, $user, $format,
+ $translate = true) {
if (!$epoch) {
// If we're missing date information for something, the DateTime class will
// throw an exception when we try to construct an object. Since this is a
@@ -140,6 +145,9 @@
}
$date->setTimezone($zone);
-
- return PhutilTranslator::getInstance()->translateDate($format, $date);
+ if ($translate) {
+ return PhutilTranslator::getInstance()->translateDate($format, $date);
+ } else {
+ return $date->format($format);
+ }
}

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 11, 16:09 (18 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1110650
Default Alt Text
D25861.1736611762.diff (1 KB)

Event Timeline