[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorTimeTestCase extends PhabricatorTestCase { 4 5 public function testPhabricatorTimeStack() { 6 $t = 1370202281; 7 $time = PhabricatorTime::pushTime($t, 'UTC'); 8 9 $this->assertTrue(PhabricatorTime::getNow() === $t); 10 11 unset($time); 12 13 $this->assertFalse(PhabricatorTime::getNow() === $t); 14 } 15 16 public function testParseLocalTime() { 17 $u = new PhabricatorUser(); 18 $u->setTimezoneIdentifier('UTC'); 19 20 $v = new PhabricatorUser(); 21 $v->setTimezoneIdentifier('America/Los_Angeles'); 22 23 $t = 1370202281; // 2013-06-02 12:44:41 -0700 24 $time = PhabricatorTime::pushTime($t, 'America/Los_Angeles'); 25 26 $this->assertEqual( 27 $t, 28 PhabricatorTime::parseLocalTime('now', $u)); 29 $this->assertEqual( 30 $t, 31 PhabricatorTime::parseLocalTime('now', $v)); 32 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)); 39 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)); 46 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)); 53 54 $this->assertEqual( 55 $t + 3600, 56 PhabricatorTime::parseLocalTime('+1 hour', $u)); 57 $this->assertEqual( 58 $t + 3600, 59 PhabricatorTime::parseLocalTime('+1 hour', $v)); 60 61 unset($time); 62 63 $t = 1370239200; // 2013-06-02 23:00:00 -0700 64 $time = PhabricatorTime::pushTime($t, 'America/Los_Angeles'); 65 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)); 74 75 unset($time); 76 } 77 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |