3 final class PhabricatorTimeTestCase
extends PhabricatorTestCase
{
5 public function testPhabricatorTimeStack() {
7 $time = PhabricatorTime
::pushTime($t, 'UTC');
9 $this->assertTrue(PhabricatorTime
::getNow() === $t);
13 $this->assertFalse(PhabricatorTime
::getNow() === $t);
16 public function testParseLocalTime() {
17 $u = new PhabricatorUser();
18 $u->overrideTimezoneIdentifier('UTC');
20 $v = new PhabricatorUser();
21 $v->overrideTimezoneIdentifier('America/Los_Angeles');
23 $t = 1370202281; // 2013-06-02 12:44:41 -0700
24 $time = PhabricatorTime
::pushTime($t, 'America/Los_Angeles');
28 PhabricatorTime
::parseLocalTime('now', $u));
31 PhabricatorTime
::parseLocalTime('now', $v));
35 PhabricatorTime
::parseLocalTime('2013-06-02 12:44:41 -0700', $u));
38 PhabricatorTime
::parseLocalTime('2013-06-02 12:44:41 -0700', $v));
42 PhabricatorTime
::parseLocalTime('2013-06-02 12:44:41 PDT', $u));
45 PhabricatorTime
::parseLocalTime('2013-06-02 12:44:41 PDT', $v));
49 PhabricatorTime
::parseLocalTime('2013-06-02 19:44:41', $u));
52 PhabricatorTime
::parseLocalTime('2013-06-02 12:44:41', $v));
56 PhabricatorTime
::parseLocalTime('+1 hour', $u));
59 PhabricatorTime
::parseLocalTime('+1 hour', $v));
63 $t = 1370239200; // 2013-06-02 23:00:00 -0700
64 $time = PhabricatorTime
::pushTime($t, 'America/Los_Angeles');
66 // For the UTC user, midnight was 6 hours ago because it's early in the
67 // morning for htem. For the PDT user, midnight was 23 hours ago.
69 $t +
(-6 * 3600) +
60,
70 PhabricatorTime
::parseLocalTime('12:01:00 AM', $u));
72 $t +
(-23 * 3600) +
60,
73 PhabricatorTime
::parseLocalTime('12:01:00 AM', $v));