Changeset View
Standalone View
src/applications/settings/panel/PhabricatorDateTimeSettingsPanel.php
| Show All 13 Lines | public function getPanelGroup() { | ||||
| return pht('Account Information'); | return pht('Account Information'); | ||||
| } | } | ||||
| public function processRequest(AphrontRequest $request) { | public function processRequest(AphrontRequest $request) { | ||||
| $user = $request->getUser(); | $user = $request->getUser(); | ||||
| $username = $user->getUsername(); | $username = $user->getUsername(); | ||||
| $pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; | $pref_time = PhabricatorUserPreferences::PREFERENCE_TIME_FORMAT; | ||||
| $pref_date = PhabricatorUserPreferences::PREFERENCE_DATE_FORMAT; | |||||
| $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; | $pref_week_start = PhabricatorUserPreferences::PREFERENCE_WEEK_START_DAY; | ||||
| $preferences = $user->loadPreferences(); | $preferences = $user->loadPreferences(); | ||||
| $errors = array(); | $errors = array(); | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $new_timezone = $request->getStr('timezone'); | $new_timezone = $request->getStr('timezone'); | ||||
| if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) { | if (in_array($new_timezone, DateTimeZone::listIdentifiers(), true)) { | ||||
| $user->setTimezoneIdentifier($new_timezone); | $user->setTimezoneIdentifier($new_timezone); | ||||
| } else { | } else { | ||||
| $errors[] = pht('The selected timezone is not a valid timezone.'); | $errors[] = pht('The selected timezone is not a valid timezone.'); | ||||
| } | } | ||||
| $preferences->setPreference( | $preferences | ||||
| ->setPreference( | |||||
| $pref_time, | $pref_time, | ||||
| $request->getStr($pref_time)); | $request->getStr($pref_time)) | ||||
| $preferences->setPreference( | ->setPreference( | ||||
| $pref_date, | |||||
| $request->getStr($pref_date)) | |||||
| ->setPreference( | |||||
| $pref_week_start, | $pref_week_start, | ||||
| $request->getStr($pref_week_start)); | $request->getStr($pref_week_start)); | ||||
| if (!$errors) { | if (!$errors) { | ||||
| $preferences->save(); | $preferences->save(); | ||||
| $user->save(); | $user->save(); | ||||
| return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
| ->setURI($this->getPanelURI('?saved=true')); | ->setURI($this->getPanelURI('?saved=true')); | ||||
| } | } | ||||
| } | } | ||||
| Show All 18 Lines | $form | ||||
| 'g:i A' => pht('12-hour (2:34 PM)'), | 'g:i A' => pht('12-hour (2:34 PM)'), | ||||
| 'H:i' => pht('24-hour (14:34)'), | 'H:i' => pht('24-hour (14:34)'), | ||||
| )) | )) | ||||
| ->setCaption( | ->setCaption( | ||||
| pht('Format used when rendering a time of day.')) | pht('Format used when rendering a time of day.')) | ||||
| ->setValue($preferences->getPreference($pref_time))) | ->setValue($preferences->getPreference($pref_time))) | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormSelectControl()) | id(new AphrontFormSelectControl()) | ||||
| ->setLabel(pht('Date Format')) | |||||
| ->setName($pref_date) | |||||
| ->setOptions(array( | |||||
eadler: Can you add ISO 8601 as well (big endian with - as a separator) | |||||
Not Done Inline ActionsProbably just changing the "Big-Endian" format is enough, as the countries that use that order in practice do not use / as a separator (they use Chinese or Korean characters but ISO format will be familiar to them too). jasonrumney: Probably just changing the "Big-Endian" format is enough, as the countries that use that order… | |||||
Not Done Inline ActionsThat's fine with me too. eadler: That's fine with me too. | |||||
Not Done Inline ActionsYep, this makes sense. lpriestley: Yep, this makes sense. | |||||
| 'Y-m-d' => pht('ISO 8601 (2000-02-28)'), | |||||
| 'n/j/Y' => pht('US (2/28/2000)'), | |||||
| 'd-m-Y' => pht('European (28-02-2000)'), | |||||
Done Inline ActionsMaybe consider calling these "European" (or "Non-US", or "Civilized", or similar, to taste) and "ISO 8601". In particular, "Big-Endian" and "Little-Endian" have a strong significance in programming contexts already (byte order), and these terms feel out of place to me. I theorize other users with C experience may also find the terms unclear. I also think we should make ISO 8601 the default format -- it is unambiguous, while the other two formats are potentially confusing to a lot of users (either all US users or all non-US users). epriestley: Maybe consider calling these "European" (or "Non-US", or "Civilized", or similar, to taste) and… | |||||
| )) | |||||
| ->setCaption( | |||||
| pht('Format used when rendering a date.')) | |||||
| ->setValue($preferences->getPreference($pref_date))) | |||||
| ->appendChild( | |||||
| id(new AphrontFormSelectControl()) | |||||
| ->setLabel(pht('Week Starts On')) | ->setLabel(pht('Week Starts On')) | ||||
| ->setOptions($this->getWeekDays()) | ->setOptions($this->getWeekDays()) | ||||
| ->setName($pref_week_start) | ->setName($pref_week_start) | ||||
| ->setCaption( | ->setCaption( | ||||
| pht('Calendar weeks will start with this day.')) | pht('Calendar weeks will start with this day.')) | ||||
| ->setValue($preferences->getPreference($pref_week_start, 0))) | ->setValue($preferences->getPreference($pref_week_start, 0))) | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new AphrontFormSubmitControl()) | id(new AphrontFormSubmitControl()) | ||||
| Show All 25 Lines | |||||
Can you add ISO 8601 as well (big endian with - as a separator)