@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

When the JS "Intl" API is available, use it to guess the timezone

Summary:
Ref T3025. Chrome gives us an easily-accessible, much better guess at which timezone the user is in.

Firefox also exposes "Intl" but this doesn't seem to be a reliable method to read the timezone.

Test Plan:
In Chrome, swapped my system date/time between zones, clicked the "reconcile" popup, got the dropdown prefilled accurately.

In Safari (no `Intl` API) got the normal flow with no default selected.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T3025

Differential Revision: https://secure.phabricator.com/D15962

+29 -9
+8 -8
resources/celerity/map.php
··· 8 8 return array( 9 9 'names' => array( 10 10 'core.pkg.css' => '8aeacc63', 11 - 'core.pkg.js' => '7b44c14f', 11 + 'core.pkg.js' => '50e9228e', 12 12 'darkconsole.pkg.js' => 'e7393ebb', 13 13 'differential.pkg.css' => '33da0633', 14 14 'differential.pkg.js' => '4b7d8f19', ··· 477 477 'rsrc/js/core/behavior-choose-control.js' => '327a00d1', 478 478 'rsrc/js/core/behavior-crop.js' => 'fa0f4fc2', 479 479 'rsrc/js/core/behavior-dark-console.js' => 'f411b6ae', 480 - 'rsrc/js/core/behavior-detect-timezone.js' => 'ae9f2ec9', 480 + 'rsrc/js/core/behavior-detect-timezone.js' => '4c193c96', 481 481 'rsrc/js/core/behavior-device.js' => 'bb1dd507', 482 482 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '484a6e22', 483 483 'rsrc/js/core/behavior-error-log.js' => '6882e80a', ··· 602 602 'javelin-behavior-dashboard-tab-panel' => 'd4eecc63', 603 603 'javelin-behavior-day-view' => '5c46cff2', 604 604 'javelin-behavior-desktop-notifications-control' => 'edd1ba66', 605 - 'javelin-behavior-detect-timezone' => 'ae9f2ec9', 605 + 'javelin-behavior-detect-timezone' => '4c193c96', 606 606 'javelin-behavior-device' => 'bb1dd507', 607 607 'javelin-behavior-differential-add-reviewers-and-ccs' => 'e10f8e18', 608 608 'javelin-behavior-differential-comment-jump' => '4fdb476d', ··· 1226 1226 'javelin-util', 1227 1227 'phabricator-shaped-request', 1228 1228 ), 1229 + '4c193c96' => array( 1230 + 'javelin-behavior', 1231 + 'javelin-uri', 1232 + 'phabricator-notification', 1233 + ), 1229 1234 '4e3e79a6' => array( 1230 1235 'javelin-behavior', 1231 1236 'javelin-stratcom', ··· 1743 1748 'javelin-router', 1744 1749 'javelin-util', 1745 1750 'phabricator-busy', 1746 - ), 1747 - 'ae9f2ec9' => array( 1748 - 'javelin-behavior', 1749 - 'javelin-uri', 1750 - 'phabricator-notification', 1751 1751 ), 1752 1752 'b003d4fb' => array( 1753 1753 'javelin-behavior',
+9 -1
src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
··· 74 74 ->addCancelButton('/', pht('Done')); 75 75 } 76 76 77 + // If we have a guess at the timezone from the client, select it as the 78 + // default. 79 + $guess = $request->getStr('guess'); 80 + if (empty($options[$guess])) { 81 + $guess = 'ignore'; 82 + } 83 + 77 84 $form = id(new AphrontFormView()) 78 85 ->appendChild( 79 86 id(new AphrontFormSelectControl()) 80 87 ->setName('timezone') 81 88 ->setLabel(pht('Timezone')) 82 - ->setOptions($options)); 89 + ->setOptions($options) 90 + ->setValue($guess)); 83 91 84 92 return $this->newDialog() 85 93 ->setTitle(pht('Adjust Timezone'))
+12
webroot/rsrc/js/core/behavior-detect-timezone.js
··· 45 45 46 46 var uri = config.uri + offset + '/'; 47 47 48 + // Some browsers (notably, Chrome) expose an "Intl" API which gives us 49 + // direct access to a timezone setting. If we are able to read this, use 50 + // it to guess which timezone the user is in so we can prefill the 51 + // dropdown. 52 + try { 53 + var guess = Intl.DateTimeFormat().resolvedOptions().timeZone; 54 + uri = JX.$U(uri).setQueryParam('guess', guess); 55 + } catch (error) { 56 + // Ignore any errors here, we'll just make the user pick from the big 57 + // list. 58 + } 59 + 48 60 new JX.Workflow(uri) 49 61 .start(); 50 62 });