Differential D16005 Diff 38527 src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/controller/PhabricatorSettingsTimezoneController.php
| Show All 25 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| $settings_help = pht( | $settings_help = pht( | ||||
| 'You can change your date and time preferences in Settings.'); | 'You can change your date and time preferences in Settings.'); | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $timezone = $request->getStr('timezone'); | $timezone = $request->getStr('timezone'); | ||||
| $pref_ignore = PhabricatorUserPreferences::PREFERENCE_IGNORE_OFFSET; | $pref_ignore = PhabricatorUserPreferences::PREFERENCE_IGNORE_OFFSET; | ||||
| $pref_timezone = PhabricatorTimezoneSetting::SETTINGKEY; | |||||
| $preferences = $viewer->loadPreferences(); | $preferences = $viewer->loadPreferences(); | ||||
| if ($timezone == 'ignore') { | if ($timezone == 'ignore') { | ||||
| $preferences | $preferences | ||||
| ->setPreference($pref_ignore, $client_offset) | ->setPreference($pref_ignore, $client_offset) | ||||
| ->save(); | ->save(); | ||||
| return $this->newDialog() | return $this->newDialog() | ||||
| ->setTitle(pht('Conflict Ignored')) | ->setTitle(pht('Conflict Ignored')) | ||||
| ->appendParagraph( | ->appendParagraph( | ||||
| pht( | pht( | ||||
| 'The conflict between your browser and profile timezone '. | 'The conflict between your browser and profile timezone '. | ||||
| 'settings will be ignored.')) | 'settings will be ignored.')) | ||||
| ->appendParagraph($settings_help) | ->appendParagraph($settings_help) | ||||
| ->addCancelButton('/', pht('Done')); | ->addCancelButton('/', pht('Done')); | ||||
| } | } | ||||
| if (isset($options[$timezone])) { | if (isset($options[$timezone])) { | ||||
| $preferences | $preferences | ||||
| ->setPreference($pref_ignore, null) | ->setPreference($pref_ignore, null) | ||||
| ->setPreference($pref_timezone, $timezone) | |||||
| ->save(); | ->save(); | ||||
| $viewer | $viewer->clearCacheData( | ||||
| ->setTimezoneIdentifier($timezone) | PhabricatorUserPreferencesCacheType::KEY_PREFERENCES); | ||||
| ->save(); | |||||
| } | } | ||||
| } | } | ||||
| $server_offset = $viewer->getTimeZoneOffset(); | $server_offset = $viewer->getTimeZoneOffset(); | ||||
| if ($client_offset == $server_offset) { | if ($client_offset == $server_offset) { | ||||
| return $this->newDialog() | return $this->newDialog() | ||||
| ->setTitle(pht('Timezone Calibrated')) | ->setTitle(pht('Timezone Calibrated')) | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | return $this->newDialog() | ||||
| ->addCancelButton(pht('Cancel')) | ->addCancelButton(pht('Cancel')) | ||||
| ->addSubmitButton(pht('Change Timezone')); | ->addSubmitButton(pht('Change Timezone')); | ||||
| } | } | ||||
| private function formatOffset($offset) { | private function formatOffset($offset) { | ||||
| $offset = $offset / 60; | $offset = $offset / 60; | ||||
| if ($offset >= 0) { | if ($offset >= 0) { | ||||
| return pht('GMT-%d', $offset); | return pht('UTC-%d', $offset); | ||||
| } else { | } else { | ||||
| return pht('GMT+%d', -$offset); | return pht('UTC+%d', -$offset); | ||||
epriestley: I guess "GMT" is deprecated and "UTC" is the new hotness. | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
I guess "GMT" is deprecated and "UTC" is the new hotness.