mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 08:12:40 +01:00
Render timezone names more readably, with spaces rather than underscores ("America/Los Angeles", not "America/Los_Angeles").
Summary: See downstream <https://phabricator.wikimedia.org/T902>. Currently, timezones are rendered with their raw internal names (like `America/Los_Angeles`) which include underscores. Replacing underscores with spaces is a more human-readable (and perhaps meaningfully better for things like screen readers, although this is pure speculation). There's some vague argument against this, like "administrators may need to set a raw internal value in `phabricator.timezone` and this could mislead them", but we already give a pretty good error message if you do this and could improve hinting if necessary. Test Plan: Viewed timezone list in {nav Settings} and the timezone "reconcile" dialog, saw a more-readable "Los Angeles". Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D20559
This commit is contained in:
parent
53b9acfb7d
commit
e5a1681903
3 changed files with 20 additions and 2 deletions
|
@ -20,7 +20,8 @@ final class PhabricatorSettingsTimezoneController
|
|||
$zone = new DateTimeZone($identifier);
|
||||
$offset = -($zone->getOffset($now) / 60);
|
||||
if ($offset == $client_offset) {
|
||||
$options[$identifier] = $identifier;
|
||||
$name = PhabricatorTime::getTimezoneDisplayName($identifier);
|
||||
$options[$identifier] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,9 +81,16 @@ final class PhabricatorTimezoneSetting
|
|||
}
|
||||
|
||||
sort($group);
|
||||
|
||||
$group_map = array();
|
||||
foreach ($group as $identifier) {
|
||||
$name = PhabricatorTime::getTimezoneDisplayName($identifier);
|
||||
$group_map[$identifier] = $name;
|
||||
}
|
||||
|
||||
$option_groups[] = array(
|
||||
'label' => $label,
|
||||
'options' => array_fuse($group),
|
||||
'options' => $group_map,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,4 +78,14 @@ final class PhabricatorTime extends Phobject {
|
|||
return $datetime;
|
||||
}
|
||||
|
||||
public static function getTimezoneDisplayName($raw_identifier) {
|
||||
|
||||
// Internal identifiers have names like "America/Los_Angeles", but this is
|
||||
// just an implementation detail and we can render them in a more human
|
||||
// readable format with spaces.
|
||||
$name = str_replace('_', ' ', $raw_identifier);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue