1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-17 01:08:41 +01:00

Fix two minor timezone display issues

Summary:
Ref T13263. Two minor issues:

  - The "reconcile" dialog shows the wrong sign because JS signs differ from normal signs (for example, PST or PDT or whatever we're in right now is shown as "UTC+7", but should be "UTC-7").
  - The big dropdown of possible timezones lumps "UTC+X:30" timezones into "UTC+X".

Test Plan:
  - Reconciled "America/Nome", saw negative UTC offsets for "America/Nome" and "America/Los_Angeles" (previously: improperly positive).
  - Viewed the big timzone list, saw ":30" and ":45" timezones grouped/labeled more accurately.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13263

Differential Revision: https://secure.phabricator.com/D20314
This commit is contained in:
epriestley 2019-03-22 15:04:36 -07:00
parent 2ebe675ae5
commit 1d73ae3b50
2 changed files with 13 additions and 5 deletions

View file

@ -113,6 +113,11 @@ final class PhabricatorSettingsTimezoneController
} }
private function formatOffset($offset) { private function formatOffset($offset) {
// This controller works with client-side (Javascript) offsets, which have
// the opposite sign we might expect -- for example "UTC-3" is a positive
// offset. Invert the sign before rendering the offset.
$offset = -1 * $offset;
$hours = $offset / 60; $hours = $offset / 60;
// Non-integer number of hours off UTC? // Non-integer number of hours off UTC?
if ($offset % 60) { if ($offset % 60) {

View file

@ -57,11 +57,11 @@ final class PhabricatorTimezoneSetting
$groups = array(); $groups = array();
foreach ($timezones as $timezone) { foreach ($timezones as $timezone) {
$zone = new DateTimeZone($timezone); $zone = new DateTimeZone($timezone);
$offset = -($zone->getOffset($now) / (60 * 60)); $offset = ($zone->getOffset($now) / 60);
$groups[$offset][] = $timezone; $groups[$offset][] = $timezone;
} }
krsort($groups); ksort($groups);
$option_groups = array( $option_groups = array(
array( array(
@ -71,10 +71,13 @@ final class PhabricatorTimezoneSetting
); );
foreach ($groups as $offset => $group) { foreach ($groups as $offset => $group) {
if ($offset >= 0) { $hours = $offset / 60;
$label = pht('UTC-%d', $offset); $minutes = abs($offset % 60);
if ($offset % 60) {
$label = pht('UTC%+d:%02d', $hours, $minutes);
} else { } else {
$label = pht('UTC+%d', -$offset); $label = pht('UTC%+d', $hours);
} }
sort($group); sort($group);