Beispiel #1
0
 public function testHowToKnowIfItIsBeforeAfterEqualAGivenDate()
 {
     $timepoint = new TimePoint(2013, 3, 12, 18, 27);
     $datebefore = new Date(2013, 1, 1);
     $dateafter = new Date(2013, 8, 15);
     $dateequal = new Date(2013, 3, 12);
     $this->assertEquals(true, $datebefore->isBefore($timepoint->getDate()));
     $this->assertEquals(true, $dateafter->isAfter($timepoint->getDate()));
     $this->assertEquals(true, $dateequal->isEquals($timepoint->getDate()));
 }
 public function testNextEquals()
 {
     $startDate = new Date(2012, 01, 01);
     $endDate = new Date(2012, 01, 03);
     $interval = new DateInterval($startDate, $endDate);
     $this->assertEquals($startDate, $interval->getBegin());
     $this->assertEquals(new Date(2012, 01, 02), $interval->getBegin()->next());
     $this->assertEquals(new Date(2012, 01, 03), $interval->getBegin()->next()->next());
     $this->assertFalse($endDate->isEquals($interval->getBegin()));
     $this->assertFalse($endDate->isEquals($interval->getBegin()->next()));
     $this->assertTrue($endDate->isEquals($interval->getBegin()->next()->next()));
 }
Beispiel #3
0
 public function testToDateTime()
 {
     $date = new Date(2013, 1, 1);
     $this->assertEquals(new \DateTime('2013-01-01 00:00:00'), $date->toDateTime());
 }
Beispiel #4
0
 /**
  * Use cases :
  *  - Calculate difference between 2 days
  *  - Fetch the position of a date from another
  *  - How many days form my birthday
  *
  * Returns a Duration Class @see Ddd\Time\Model\Duration.
  *
  */
 public function testHowToKnowDiffBetweenItAndAnOtherDate()
 {
     $jan1 = new Date(2013, 1, 1);
     $jan10 = new Date(2013, 1, 10);
     $diff = $jan1->diff($jan10);
     $this->assertInstanceOf('Ddd\\Time\\Model\\Duration', $diff);
     $this->assertEquals($diff, new Duration(9, TimeUnit::day()));
 }