mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +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:
parent
2ebe675ae5
commit
1d73ae3b50
2 changed files with 13 additions and 5 deletions
|
@ -113,6 +113,11 @@ final class PhabricatorSettingsTimezoneController
|
|||
}
|
||||
|
||||
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;
|
||||
// Non-integer number of hours off UTC?
|
||||
if ($offset % 60) {
|
||||
|
|
|
@ -57,11 +57,11 @@ final class PhabricatorTimezoneSetting
|
|||
$groups = array();
|
||||
foreach ($timezones as $timezone) {
|
||||
$zone = new DateTimeZone($timezone);
|
||||
$offset = -($zone->getOffset($now) / (60 * 60));
|
||||
$offset = ($zone->getOffset($now) / 60);
|
||||
$groups[$offset][] = $timezone;
|
||||
}
|
||||
|
||||
krsort($groups);
|
||||
ksort($groups);
|
||||
|
||||
$option_groups = array(
|
||||
array(
|
||||
|
@ -71,10 +71,13 @@ final class PhabricatorTimezoneSetting
|
|||
);
|
||||
|
||||
foreach ($groups as $offset => $group) {
|
||||
if ($offset >= 0) {
|
||||
$label = pht('UTC-%d', $offset);
|
||||
$hours = $offset / 60;
|
||||
$minutes = abs($offset % 60);
|
||||
|
||||
if ($offset % 60) {
|
||||
$label = pht('UTC%+d:%02d', $hours, $minutes);
|
||||
} else {
|
||||
$label = pht('UTC+%d', -$offset);
|
||||
$label = pht('UTC%+d', $hours);
|
||||
}
|
||||
|
||||
sort($group);
|
||||
|
|
Loading…
Reference in a new issue