@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.

In email, render dates with an explicit timezone offset

Summary:
Fixes T10633. When generating email about a transaction which adjusts a date, render the offset explicitly (like "UTC-7").

This makes it more clear in cases like this:

- mail is being sent to multiple users, and not necessarily using the viewer's settings;
- you get some mail while travelling and aren't sure which timezone setting it generated under.

Test Plan: Rendered in text mode, saw UTC offset.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10633

Differential Revision: https://secure.phabricator.com/D16287

+28 -7
+8
src/applications/people/storage/PhabricatorUser.php
··· 832 832 return $offset; 833 833 } 834 834 835 + public function getTimeZoneOffsetInHours() { 836 + $offset = $this->getTimeZoneOffset(); 837 + $offset = (int)round($offset / 60); 838 + $offset = -$offset; 839 + 840 + return $offset; 841 + } 842 + 835 843 public function formatShortDateTime($when, $now = null) { 836 844 if ($now === null) { 837 845 $now = PhabricatorTime::getNow();
+20 -7
src/applications/transactions/storage/PhabricatorModularTransactionType.php
··· 141 141 $viewer = $this->getViewer(); 142 142 $display = $viewer->renderHandle($phid); 143 143 144 - $rendering_target = $this->getStorage()->getRenderingTarget(); 145 - if ($rendering_target == PhabricatorApplicationTransaction::TARGET_TEXT) { 144 + if ($this->isTextMode()) { 146 145 $display->setAsText(true); 147 146 } 148 147 ··· 154 153 $display = $viewer->renderHandleList($phids) 155 154 ->setAsInline(true); 156 155 157 - $rendering_target = $this->getStorage()->getRenderingTarget(); 158 - if ($rendering_target == PhabricatorApplicationTransaction::TARGET_TEXT) { 156 + if ($this->isTextMode()) { 159 157 $display->setAsText(true); 160 158 } 161 159 ··· 163 161 } 164 162 165 163 final protected function renderValue($value) { 166 - $rendering_target = $this->getStorage()->getRenderingTarget(); 167 - if ($rendering_target == PhabricatorApplicationTransaction::TARGET_TEXT) { 164 + if ($this->isTextMode()) { 168 165 return sprintf('"%s"', $value); 169 166 } 170 167 ··· 189 186 190 187 $display = phabricator_datetime($epoch, $viewer); 191 188 192 - // TODO: When rendering for email, include the UTC offset. See T10633. 189 + // When rendering to text, we explicitly render the offset from UTC to 190 + // provide context to the date: the mail may be generating with the 191 + // server's settings, or the user may later refer back to it after changing 192 + // timezones. 193 + 194 + if ($this->isTextMode()) { 195 + $offset = $viewer->getTimeZoneOffsetInHours(); 196 + if ($offset >= 0) { 197 + $display = pht('%s (UTC+%d)', $display, $offset); 198 + } else { 199 + $display = pht('%s (UTC-%d)', $display, abs($offset)); 200 + } 201 + } 193 202 194 203 return $this->renderValue($display); 195 204 } ··· 231 240 return !strlen($value); 232 241 } 233 242 243 + private function isTextMode() { 244 + $target = $this->getStorage()->getRenderingTarget(); 245 + return ($target == PhabricatorApplicationTransaction::TARGET_TEXT); 246 + } 234 247 235 248 }