Example #1
0
 public function testCopyEnsureTzIsCopied()
 {
     $dating = IntlCarbon::createFromDate(2000, 1, 1, 'Europe/London');
     $dating2 = $dating->copy();
     $this->assertSame($dating->tzName, $dating2->tzName);
     $this->assertSame($dating->offset, $dating2->offset);
 }
 public function testGetTzName()
 {
     $dt = IntlCarbon::createFromDate(2000, 1, 1, 'America/Toronto');
     $this->assertSame('America/Toronto', $dt->tzName);
 }
Example #3
0
 public function testAddDayPassingArg()
 {
     $this->assertSame(12, IntlCarbon::createFromDate(1975, 5, 10)->addDay(2)->day);
 }
 public function testDaySetterWithWrap()
 {
     $d = IntlCarbon::createFromDate(2012, 8, 5);
     $d->day = 32;
     $this->assertSame(1, $d->day);
 }
 public function testIsBirthday()
 {
     $dt1 = IntlCarbon::createFromDate(1987, 4, 23);
     $dt2 = IntlCarbon::createFromDate(2014, 9, 26);
     $dt3 = IntlCarbon::createFromDate(2014, 4, 23);
     $this->assertFalse($dt2->isBirthday($dt1));
     $this->assertTrue($dt3->isBirthday($dt1));
 }
Example #6
0
 public function testIsSameDayFalse()
 {
     $current = IntlCarbon::createFromDate(2012, 1, 2);
     $this->assertFalse($current->isSameDay(IntlCarbon::createFromDate(2012, 1, 3)));
 }
 public function testFluidSetTime()
 {
     $d = IntlCarbon::createFromDate(2000, 1, 1);
     $this->assertTrue($d->setTime(25, 61, 61) instanceof IntlCarbon);
     $this->assertIntlCarbon($d, 2000, 1, 2, 2, 2, 1);
 }
 public function testCreateFromDateWithDateTimeZone()
 {
     $d = IntlCarbon::createFromDate(1975, 5, 21, new \DateTimeZone('Europe/London'));
     $this->assertIntlCarbon($d, 1975, 5, 21);
     $this->assertSame('Europe/London', $d->tzName);
 }
 public function test3rdWednesdayOfYear()
 {
     $d = IntlCarbon::createFromDate(1975, 8, 5)->nthOfYear(3, 3);
     $this->assertIntlCarbon($d, 1975, 1, 15, 0, 0, 0);
 }
Example #10
0
 public function testDiffInSecondsWithTimezones()
 {
     $dtOttawa = IntlCarbon::createFromDate(2000, 1, 1, 'America/Toronto');
     $dtVancouver = IntlCarbon::createFromDate(2000, 1, 1, 'America/Vancouver');
     $this->assertSame(3 * 60 * 60, $dtOttawa->diffInSeconds($dtVancouver));
 }