Consolidate some datetime code and add unit tests
Summary: See D6115. Test Plan: - Ran unit tests. - Viewed reports. - Created a countdown. - Searched chatlog. - Searched pastes by created date. Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D6116
This commit is contained in:
@@ -709,11 +709,8 @@ final class ManiphestReportController extends ManiphestController {
|
||||
// Do locale-aware parsing so that the user's timezone is assumed for
|
||||
// time windows like "3 PM", rather than assuming the server timezone.
|
||||
|
||||
$timezone = new DateTimeZone($user->getTimezoneIdentifier());
|
||||
try {
|
||||
$date = new DateTime($window_str, $timezone);
|
||||
$window_epoch = $date->format('U');
|
||||
} catch (Exception $e) {
|
||||
$window_epoch = PhabricatorTime::parseLocalTime($window_str, $user);
|
||||
if (!$window_epoch) {
|
||||
$error = 'Invalid';
|
||||
$window_epoch = time() - (60 * 60 * 24 * 7);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user