Esempio n. 1
0
 public function testCopyEnsureTzIsCopied()
 {
     $dating = Date::createFromDate(2000, 1, 1, 'Europe/London');
     $dating2 = $dating->copy();
     $this->assertSame($dating->getTimezoneName(), $dating2->getTimezoneName());
     $this->assertSame($dating->getOffset(), $dating2->getOffset());
 }
Esempio n. 2
0
 public function testAddDayPassingArg()
 {
     $this->assertSame(12, Date::createFromDate(1975, 5, 10)->addDay(2)->getDay());
 }
Esempio n. 3
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testCreateWithInvalidTimezoneOffset()
 {
     Date::createFromDate(2000, 1, 1, 'Mars/Somewhere');
 }
Esempio n. 4
0
 public function testGetTimezoneName()
 {
     $dt = Date::createFromDate(2000, 1, 1, 'America/Toronto');
     $this->assertSame('America/Toronto', $dt->getTimezoneName());
     $dt = Date::createFromDate(2000, 1, 1, -5);
     $this->assertSame('-05:00', $dt->getTimezoneName());
 }
Esempio n. 5
0
 public function testDaySetterWithWrap()
 {
     $d = Date::createFromDate(2012, 8, 5)->day(32);
     $this->assertSame(1, $d->getDay());
 }
Esempio n. 6
0
 public function testFluidSetTime()
 {
     $d = Date::createFromDate(2000, 1, 1)->setTime(25, 61, 61);
     $this->assertTrue($d instanceof Date);
     $this->assertDate($d, 2000, 1, 2, 2, 2, 1);
 }
Esempio n. 7
0
 public function test3rdWednesdayOfYear()
 {
     $d = Date::createFromDate(1975, 8, 5)->nthOfYear(3, 3);
     $this->assertDate($d, 1975, 1, 15, 0, 0, 0);
 }
Esempio n. 8
0
 public function testIsBirthday()
 {
     $dt = Date::now();
     $aBirthday = $dt->subYear();
     $this->assertTrue($aBirthday->isBirthday());
     $notABirthday = $dt->subDay();
     $this->assertFalse($notABirthday->isBirthday());
     $alsoNotABirthday = $dt->addDays(2);
     $this->assertFalse($alsoNotABirthday->isBirthday());
     $dt1 = Date::createFromDate(1987, 4, 23);
     $dt2 = Date::createFromDate(2014, 9, 26);
     $dt3 = Date::createFromDate(2014, 4, 23);
     $this->assertFalse($dt2->isBirthday($dt1));
     $this->assertTrue($dt3->isBirthday($dt1));
 }
Esempio n. 9
0
 public function testDiffInSecondsWithTimezones()
 {
     $dtOttawa = Date::createFromDate(2000, 1, 1, 'America/Toronto');
     $dtVancouver = Date::createFromDate(2000, 1, 1, 'America/Vancouver');
     $this->assertSame(3 * 60 * 60, $dtOttawa->diffInSeconds($dtVancouver));
 }
Esempio n. 10
0
File: IsTest.php Progetto: hmlb/date
 public function testIsSaturday()
 {
     // True in the past past
     $this->assertTrue(Date::createFromDate(2015, 6, 6)->isSaturday());
     $this->assertTrue(Date::now()->subWeek()->previous(Date::SATURDAY)->isSaturday());
     // True in the future
     $this->assertTrue(Date::now()->addWeek()->previous(Date::SATURDAY)->isSaturday());
     $this->assertTrue(Date::now()->addMonth()->previous(Date::SATURDAY)->isSaturday());
     // False in the past
     $this->assertFalse(Date::now()->subWeek()->previous(Date::SUNDAY)->isSaturday());
     $this->assertFalse(Date::now()->subMonth()->previous(Date::SUNDAY)->isSaturday());
     // False in the future
     $this->assertFalse(Date::now()->addWeek()->previous(Date::SUNDAY)->isSaturday());
     $this->assertFalse(Date::now()->addMonth()->previous(Date::SUNDAY)->isSaturday());
 }
Esempio n. 11
0
 public function testCreateFromDateWithDateTimeZone()
 {
     $d = Date::createFromDate(1975, 5, 21, new \DateTimeZone('Europe/London'));
     $this->assertDate($d, 1975, 5, 21);
     $this->assertSame('Europe/London', $d->getTimezoneName());
 }