public function testParseSettingTimezoneWithString() { $timezone = 'Asia/Tokyo'; $dtz = new \DateTimeZone($timezone); $dt = new \DateTime('now', $dtz); $dayLightSavingTimeOffset = $dt->format('I'); $c = IntlCarbon::parse('now', $timezone); $this->assertSame($timezone, $c->tzName); $this->assertSame(9 + $dayLightSavingTimeOffset, $c->offsetHours); }
public function testMicroGetter() { $micro = 345678; $d = IntlCarbon::parse('2014-01-05 12:34:11.' . $micro); $this->assertSame($micro, $d->micro); }
public function testTimeZoneWithTestValueSet() { $notNow = IntlCarbon::parse('2013-07-01 12:00:00', 'America/New_York'); IntlCarbon::setTestNow($notNow); $this->assertSame('2013-07-01T12:00:00-0400', IntlCarbon::parse('now')->toIso8601String()); $this->assertSame('2013-07-01T11:00:00-0500', IntlCarbon::parse('now', 'America/Mexico_City')->toIso8601String()); $this->assertSame('2013-07-01T09:00:00-0700', IntlCarbon::parse('now', 'America/Vancouver')->toIso8601String()); }
public function testDiffForHumansWithShorterMonthShouldStillBeAMonth() { $feb15 = IntlCarbon::parse('2015-02-15'); $mar15 = IntlCarbon::parse('2015-03-15'); $this->assertSame('1 month after', $mar15->diffForHumans($feb15)); }