Page MenuHomePhabricator

D17646.id42440.diff
No OneTemporary

D17646.id42440.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -4692,6 +4692,7 @@
'javelin_tag' => 'infrastructure/javelin/markup.php',
'phabricator_date' => 'view/viewutils.php',
'phabricator_datetime' => 'view/viewutils.php',
+ 'phabricator_datetimezone' => 'view/viewutils.php',
'phabricator_form' => 'infrastructure/javelin/markup.php',
'phabricator_format_local_time' => 'view/viewutils.php',
'phabricator_relative_date' => 'view/viewutils.php',
diff --git a/src/applications/calendar/notifications/PhabricatorCalendarEventNotificationView.php b/src/applications/calendar/notifications/PhabricatorCalendarEventNotificationView.php
--- a/src/applications/calendar/notifications/PhabricatorCalendarEventNotificationView.php
+++ b/src/applications/calendar/notifications/PhabricatorCalendarEventNotificationView.php
@@ -58,4 +58,12 @@
return phabricator_datetime($epoch, $viewer);
}
+ public function getDisplayTimeWithTimezone() {
+ $viewer = $this->getViewer();
+
+ $epoch = $this->getEpoch();
+ return phabricator_datetimezone($epoch, $viewer);
+ }
+
+
}
diff --git a/src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php b/src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php
--- a/src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php
+++ b/src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php
@@ -268,7 +268,7 @@
'%s is starting in %s minute(s), at %s.',
$event->getEvent()->getName(),
$event->getDisplayMinutes(),
- $event->getDisplayTime()));
+ $event->getDisplayTimeWithTimezone()));
$body->addLinkSection(
pht('EVENT DETAIL'),
diff --git a/src/applications/transactions/storage/PhabricatorModularTransactionType.php b/src/applications/transactions/storage/PhabricatorModularTransactionType.php
--- a/src/applications/transactions/storage/PhabricatorModularTransactionType.php
+++ b/src/applications/transactions/storage/PhabricatorModularTransactionType.php
@@ -234,22 +234,15 @@
if ($all_day) {
$display = phabricator_date($epoch, $viewer);
- } else {
- $display = phabricator_datetime($epoch, $viewer);
-
+ } else if ($this->isRenderingTargetExternal()) {
// When rendering to text, we explicitly render the offset from UTC to
// provide context to the date: the mail may be generating with the
// server's settings, or the user may later refer back to it after
// changing timezones.
- if ($this->isRenderingTargetExternal()) {
- $offset = $viewer->getTimeZoneOffsetInHours();
- if ($offset >= 0) {
- $display = pht('%s (UTC+%d)', $display, $offset);
- } else {
- $display = pht('%s (UTC-%d)', $display, abs($offset));
- }
- }
+ $display = phabricator_datetimezone($epoch, $viewer);
+ } else {
+ $display = phabricator_datetime($epoch, $viewer);
}
return $this->renderValue($display);
diff --git a/src/view/viewutils.php b/src/view/viewutils.php
--- a/src/view/viewutils.php
+++ b/src/view/viewutils.php
@@ -48,6 +48,24 @@
$user->getUserSetting($time_key)));
}
+function phabricator_datetimezone($epoch, $user) {
+ $datetime = phabricator_datetime($epoch, $user);
+ $timezone = phabricator_format_local_time($epoch, $user, 'T');
+
+ // Some obscure timezones just render as "+03" or "-09". Make these render
+ // as "UTC+3" instead.
+ if (preg_match('/^[+-]/', $timezone)) {
+ $timezone = (int)trim($timezone, '+');
+ if ($timezone < 0) {
+ $timezone = pht('UTC-%s', $timezone);
+ } else {
+ $timezone = pht('UTC+%s', $timezone);
+ }
+ }
+
+ return pht('%s (%s)', $datetime, $timezone);
+}
+
/**
* This function does not usually need to be called directly. Instead, call
* @{function:phabricator_date}, @{function:phabricator_time}, or

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 3, 12:25 PM (1 w, 22 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7712757
Default Alt Text
D17646.id42440.diff (3 KB)

Event Timeline