From 5cb462d511c7d938af8bfc2f6da70e7f72c0bdc7 Mon Sep 17 00:00:00 2001 From: Austin McKinley Date: Wed, 12 Dec 2018 13:02:52 -0800 Subject: [PATCH] Show more of UTC offset when user's TZ is not an integer number of hours offset Summary: See https://discourse.phabricator-community.org/t/personal-timezone-setting-mismatch-cleared-and-more-specific-cases/1680. The code has always worked correctly, but the resulting timezone mismatch warning messsage wasn't specific enough when the mismatch is by a non-integer number of hours. Test Plan: Set timezone locally to Asia/Vladivostok and in Phabricator to Australia/Adelaide (which as of today's date are 30 minutes apart) and observed a more precise error message: F6061330 Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D19873 --- .../PhabricatorSettingsTimezoneController.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php b/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php index 2e2e174e0f..51f1747b9f 100644 --- a/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php +++ b/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php @@ -63,7 +63,7 @@ final class PhabricatorSettingsTimezoneController $server_offset = $viewer->getTimeZoneOffset(); - if ($client_offset == $server_offset || $did_calibrate) { + if (($client_offset == $server_offset) || $did_calibrate) { return $this->newDialog() ->setTitle(pht('Timezone Calibrated')) ->appendParagraph( @@ -113,12 +113,13 @@ final class PhabricatorSettingsTimezoneController } private function formatOffset($offset) { - $offset = $offset / 60; - - if ($offset >= 0) { - return pht('UTC-%d', $offset); + $hours = $offset / 60; + // Non-integer number of hours off UTC? + if ($offset % 60) { + $minutes = abs($offset % 60); + return pht('UTC%+d:%02d', $hours, $minutes); } else { - return pht('UTC+%d', -$offset); + return pht('UTC%+d', $hours); } }