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:
epriestley
2013-06-03 12:58:11 -07:00
parent d016309def
commit 0b233e461e
8 changed files with 182 additions and 44 deletions

View File

@@ -207,18 +207,7 @@ abstract class PhabricatorApplicationSearchEngine {
return null;
}
$viewer = $this->requireViewer();
$timezone = new DateTimeZone($viewer->getTimezoneIdentifier());
try {
$date = new DateTime($date_time, $timezone);
$timestamp = $date->format('U');
} catch (Exception $e) {
$timestamp = null;
}
return $timestamp;
return PhabricatorTime::parseLocalTime($date_time, $this->requireViewer());
}