예제 #1
0
 /**
  * Test Converting Methods
  * 
  */
 function test_converting()
 {
     // Converting
     $timespan = Week::startingDuration(DateAndTime::withYearMonthDayHourMinuteSecondOffset(2005, 5, 4, 15, 25, 10, Duration::withHours(-4)), Duration::withDays(10));
     // asDate()
     $temp = $timespan->asDate();
     $this->assertTrue($temp->isEqualTo(Date::withYearMonthDay(2005, 5, 1)));
     // asDateAndTime()
     $temp = $timespan->asDateAndTime();
     $this->assertTrue($temp->isEqualTo(DateAndTime::withYearMonthDayHourMinuteSecond(2005, 5, 1, 00, 00, 00)));
     // asDuration()
     $temp = $timespan->asDuration();
     $this->assertTrue($temp->isEqualTo(Duration::withDays(7)));
     // asMonth()
     $temp = $timespan->asMonth();
     $this->assertTrue($temp->isEqualTo(Month::withMonthYear(5, 2005)));
     // asTime()
     $temp = $timespan->asTime();
     $dateAndTime = DateAndTime::withYearMonthDayHourMinuteSecond(2005, 5, 1, 0, 0, 0);
     $this->assertTrue($temp->isEqualTo($dateAndTime->asTime()));
     // asTimeStamp()
     $temp = $timespan->asTimeStamp();
     $this->assertTrue($temp->isEqualTo(TimeStamp::withYearMonthDayHourMinuteSecond(2005, 5, 1, 0, 0, 0)));
     // asWeek()
     $temp = $timespan->asWeek();
     $this->assertTrue($temp->isEqualTo(Week::starting(Date::withYearMonthDay(2005, 5, 1))));
     // asYear()
     $temp = $timespan->asYear();
     $this->assertTrue($temp->isEqualTo(Year::starting(Date::withYearMonthDay(2005, 5, 1))));
     // to()
     $temp = $timespan->to(Date::withYearMonthDay(2005, 10, 1));
     $comparison = Timespan::startingEnding(DateAndTime::withYearMonthDayHourMinuteSecond(2005, 5, 1, 0, 0, 0), Date::withYearMonthDay(2005, 10, 1));
     $this->assertTrue($temp->isEqualTo($comparison));
 }