Page MenuHomePhabricator

D15962.id38430.diff
No OneTemporary

D15962.id38430.diff

diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -8,7 +8,7 @@
return array(
'names' => array(
'core.pkg.css' => '8aeacc63',
- 'core.pkg.js' => '7b44c14f',
+ 'core.pkg.js' => '50e9228e',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '33da0633',
'differential.pkg.js' => '4b7d8f19',
@@ -477,7 +477,7 @@
'rsrc/js/core/behavior-choose-control.js' => '327a00d1',
'rsrc/js/core/behavior-crop.js' => 'fa0f4fc2',
'rsrc/js/core/behavior-dark-console.js' => 'f411b6ae',
- 'rsrc/js/core/behavior-detect-timezone.js' => 'ae9f2ec9',
+ 'rsrc/js/core/behavior-detect-timezone.js' => '4c193c96',
'rsrc/js/core/behavior-device.js' => 'bb1dd507',
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '484a6e22',
'rsrc/js/core/behavior-error-log.js' => '6882e80a',
@@ -602,7 +602,7 @@
'javelin-behavior-dashboard-tab-panel' => 'd4eecc63',
'javelin-behavior-day-view' => '5c46cff2',
'javelin-behavior-desktop-notifications-control' => 'edd1ba66',
- 'javelin-behavior-detect-timezone' => 'ae9f2ec9',
+ 'javelin-behavior-detect-timezone' => '4c193c96',
'javelin-behavior-device' => 'bb1dd507',
'javelin-behavior-differential-add-reviewers-and-ccs' => 'e10f8e18',
'javelin-behavior-differential-comment-jump' => '4fdb476d',
@@ -1226,6 +1226,11 @@
'javelin-util',
'phabricator-shaped-request',
),
+ '4c193c96' => array(
+ 'javelin-behavior',
+ 'javelin-uri',
+ 'phabricator-notification',
+ ),
'4e3e79a6' => array(
'javelin-behavior',
'javelin-stratcom',
@@ -1744,11 +1749,6 @@
'javelin-util',
'phabricator-busy',
),
- 'ae9f2ec9' => array(
- 'javelin-behavior',
- 'javelin-uri',
- 'phabricator-notification',
- ),
'b003d4fb' => array(
'javelin-behavior',
'javelin-stratcom',
diff --git a/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php b/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
--- a/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
+++ b/src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
@@ -74,12 +74,20 @@
->addCancelButton('/', pht('Done'));
}
+ // If we have a guess at the timezone from the client, select it as the
+ // default.
+ $guess = $request->getStr('guess');
+ if (empty($options[$guess])) {
+ $guess = 'ignore';
+ }
+
$form = id(new AphrontFormView())
->appendChild(
id(new AphrontFormSelectControl())
->setName('timezone')
->setLabel(pht('Timezone'))
- ->setOptions($options));
+ ->setOptions($options)
+ ->setValue($guess));
return $this->newDialog()
->setTitle(pht('Adjust Timezone'))
diff --git a/webroot/rsrc/js/core/behavior-detect-timezone.js b/webroot/rsrc/js/core/behavior-detect-timezone.js
--- a/webroot/rsrc/js/core/behavior-detect-timezone.js
+++ b/webroot/rsrc/js/core/behavior-detect-timezone.js
@@ -45,6 +45,18 @@
var uri = config.uri + offset + '/';
+ // Some browsers (notably, Chrome) expose an "Intl" API which gives us
+ // direct access to a timezone setting. If we are able to read this, use
+ // it to guess which timezone the user is in so we can prefill the
+ // dropdown.
+ try {
+ var guess = Intl.DateTimeFormat().resolvedOptions().timeZone;
+ uri = JX.$U(uri).setQueryParam('guess', guess);
+ } catch (error) {
+ // Ignore any errors here, we'll just make the user pick from the big
+ // list.
+ }
+
new JX.Workflow(uri)
.start();
});

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 27, 8:58 PM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7709901
Default Alt Text
D15962.id38430.diff (3 KB)

Event Timeline