Remove product literal strings in "pht()", part 18
[phabricator.git] / src / infrastructure / time / __tests__ / PhabricatorTimeTestCase.php
blob4c7b4a2f94475024a52e86c7ea6a229ecd4206d4
1 <?php
3 final class PhabricatorTimeTestCase extends PhabricatorTestCase {
5 public function testPhabricatorTimeStack() {
6 $t = 1370202281;
7 $time = PhabricatorTime::pushTime($t, 'UTC');
9 $this->assertTrue(PhabricatorTime::getNow() === $t);
11 unset($time);
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');
26 $this->assertEqual(
27 $t,
28 PhabricatorTime::parseLocalTime('now', $u));
29 $this->assertEqual(
30 $t,
31 PhabricatorTime::parseLocalTime('now', $v));
33 $this->assertEqual(
34 $t,
35 PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 -0700', $u));
36 $this->assertEqual(
37 $t,
38 PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 -0700', $v));
40 $this->assertEqual(
41 $t,
42 PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 PDT', $u));
43 $this->assertEqual(
44 $t,
45 PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 PDT', $v));
47 $this->assertEqual(
48 $t,
49 PhabricatorTime::parseLocalTime('2013-06-02 19:44:41', $u));
50 $this->assertEqual(
51 $t,
52 PhabricatorTime::parseLocalTime('2013-06-02 12:44:41', $v));
54 $this->assertEqual(
55 $t + 3600,
56 PhabricatorTime::parseLocalTime('+1 hour', $u));
57 $this->assertEqual(
58 $t + 3600,
59 PhabricatorTime::parseLocalTime('+1 hour', $v));
61 unset($time);
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.
68 $this->assertEqual(
69 $t + (-6 * 3600) + 60,
70 PhabricatorTime::parseLocalTime('12:01:00 AM', $u));
71 $this->assertEqual(
72 $t + (-23 * 3600) + 60,
73 PhabricatorTime::parseLocalTime('12:01:00 AM', $v));
75 unset($time);