From 3ea7359e161d3b44ec3288f36193d7a3368f6f9a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 4 May 2015 10:09:15 -0700 Subject: [PATCH] Support colloquial time names to dramatically improve usability of time control Summary: Ref T8024. The time control currently does not support colloquial time names frequently used in common parlance. Support these times. Test Plan: Easily specified many of the most important times in a convenient way. Reviewers: btrahan, chad, lpriestley Reviewed By: lpriestley Subscribers: johnny-bit, eadler, epriestley Maniphest Tasks: T8024 Differential Revision: https://secure.phabricator.com/D12674 --- .../form/control/AphrontFormDateControlValue.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/view/form/control/AphrontFormDateControlValue.php b/src/view/form/control/AphrontFormDateControlValue.php index 8a1e274135..58a7b754b1 100644 --- a/src/view/form/control/AphrontFormDateControlValue.php +++ b/src/view/form/control/AphrontFormDateControlValue.php @@ -179,6 +179,22 @@ final class AphrontFormDateControlValue extends Phobject { return null; } + $colloquial = array( + 'elevenses' => '11:00 AM', + 'morning tea' => '11:00 AM', + 'noon' => '12:00 PM', + 'high noon' => '12:00 PM', + 'lunch' => '12:00 PM', + 'tea time' => '3:00 PM', + 'witching hour' => '12:00 AM', + 'midnight' => '12:00 AM', + ); + + $normalized = phutil_utf8_strtolower($time); + if (isset($colloquial[$normalized])) { + $time = $colloquial[$normalized]; + } + try { $date = new DateTime("{$year}-{$month}-{$day} {$time}", $zone); $value = $date->format('U');