示例#1
0
文件: GettersTest.php 项目: hmlb/date
 public function testMicroGetter()
 {
     $micro = 345678;
     $d = Date::parse('2014-01-05 12:34:11.' . $micro);
     $this->assertSame($micro, $d->getMicro());
 }
示例#2
0
文件: DiffTest.php 项目: hmlb/date
 public function testDiffForHumansWithShorterMonthShouldStillBeAMonth()
 {
     $feb15 = Date::parse('2015-02-15');
     $mar15 = Date::parse('2015-03-15');
     $this->assertSame('1 month after', $mar15->diffForHumans($feb15));
 }
示例#3
0
 public function testParseSettingTimezoneWithString()
 {
     $timezone = 'Asia/Tokyo';
     $dtz = new \DateTimeZone($timezone);
     $dt = new \DateTime('now', $dtz);
     $dayLightSavingTimeOffset = (int) $dt->format('I');
     $c = Date::parse('now', $timezone);
     $this->assertSame($timezone, $c->getTimezoneName());
     $this->assertSame(9 + $dayLightSavingTimeOffset, $c->getOffsetHours());
 }
示例#4
0
 public function testTimeZoneWithTestValueSet()
 {
     $notNow = Date::parse('2013-07-01 12:00:00', 'America/New_York');
     Date::setTestNow($notNow);
     $this->assertSame('2013-07-01T12:00:00-0400', Date::parse('now')->toIso8601String());
     $this->assertSame('2013-07-01T11:00:00-0500', Date::parse('now', 'America/Mexico_City')->toIso8601String());
     $this->assertSame('2013-07-01T09:00:00-0700', Date::parse('now', 'America/Vancouver')->toIso8601String());
 }