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

Render timezones in event reminder mail, and render them more nicely

Summary:
Fixes T12356.

- In this mail, we currently render "6:00 AM". Instead, render "6:00 AM (PDT)" or similar. This is consistent with times in other modern Transaction mail.
- Previously, we would render "UTC-7". Render "PDT" instead. For obscure zones with no known timezone abbreviation, fall back to "UTC-7".

Test Plan:
- Used `bin/calendar notify --minutes X` to trigger notifications, read email bodies.
- Used this script to list all `T` values and checked them for sanity:

```lang=php
<?php

$now = new DateTime();

$locales = DateTimeZone::listIdentifiers();
foreach ($locales as $locale) {
$zone = new DateTimeZone($locale);
$now->setTimeZone($zone);

printf(
"%s (%s)\n",
$locale,
$now->format('T'));
}
```

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12356

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

+32 -12
+1
src/__phutil_library_map__.php
··· 4692 4692 'javelin_tag' => 'infrastructure/javelin/markup.php', 4693 4693 'phabricator_date' => 'view/viewutils.php', 4694 4694 'phabricator_datetime' => 'view/viewutils.php', 4695 + 'phabricator_datetimezone' => 'view/viewutils.php', 4695 4696 'phabricator_form' => 'infrastructure/javelin/markup.php', 4696 4697 'phabricator_format_local_time' => 'view/viewutils.php', 4697 4698 'phabricator_relative_date' => 'view/viewutils.php',
+8
src/applications/calendar/notifications/PhabricatorCalendarEventNotificationView.php
··· 58 58 return phabricator_datetime($epoch, $viewer); 59 59 } 60 60 61 + public function getDisplayTimeWithTimezone() { 62 + $viewer = $this->getViewer(); 63 + 64 + $epoch = $this->getEpoch(); 65 + return phabricator_datetimezone($epoch, $viewer); 66 + } 67 + 68 + 61 69 }
+1 -1
src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php
··· 268 268 '%s is starting in %s minute(s), at %s.', 269 269 $event->getEvent()->getName(), 270 270 $event->getDisplayMinutes(), 271 - $event->getDisplayTime())); 271 + $event->getDisplayTimeWithTimezone())); 272 272 273 273 $body->addLinkSection( 274 274 pht('EVENT DETAIL'),
+4 -11
src/applications/transactions/storage/PhabricatorModularTransactionType.php
··· 234 234 235 235 if ($all_day) { 236 236 $display = phabricator_date($epoch, $viewer); 237 - } else { 238 - $display = phabricator_datetime($epoch, $viewer); 239 - 237 + } else if ($this->isRenderingTargetExternal()) { 240 238 // When rendering to text, we explicitly render the offset from UTC to 241 239 // provide context to the date: the mail may be generating with the 242 240 // server's settings, or the user may later refer back to it after 243 241 // changing timezones. 244 242 245 - if ($this->isRenderingTargetExternal()) { 246 - $offset = $viewer->getTimeZoneOffsetInHours(); 247 - if ($offset >= 0) { 248 - $display = pht('%s (UTC+%d)', $display, $offset); 249 - } else { 250 - $display = pht('%s (UTC-%d)', $display, abs($offset)); 251 - } 252 - } 243 + $display = phabricator_datetimezone($epoch, $viewer); 244 + } else { 245 + $display = phabricator_datetime($epoch, $viewer); 253 246 } 254 247 255 248 return $this->renderValue($display);
+18
src/view/viewutils.php
··· 48 48 $user->getUserSetting($time_key))); 49 49 } 50 50 51 + function phabricator_datetimezone($epoch, $user) { 52 + $datetime = phabricator_datetime($epoch, $user); 53 + $timezone = phabricator_format_local_time($epoch, $user, 'T'); 54 + 55 + // Some obscure timezones just render as "+03" or "-09". Make these render 56 + // as "UTC+3" instead. 57 + if (preg_match('/^[+-]/', $timezone)) { 58 + $timezone = (int)trim($timezone, '+'); 59 + if ($timezone < 0) { 60 + $timezone = pht('UTC-%s', $timezone); 61 + } else { 62 + $timezone = pht('UTC+%s', $timezone); 63 + } 64 + } 65 + 66 + return pht('%s (%s)', $datetime, $timezone); 67 + } 68 + 51 69 /** 52 70 * This function does not usually need to be called directly. Instead, call 53 71 * @{function:phabricator_date}, @{function:phabricator_time}, or