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