コード例 #1
0
 /**
  * Test Accessing Methods
  * 
  */
 function test_accessing()
 {
     $timespan = Year::startingDuration(DateAndTime::withYearMonthDayHourMinuteSecondOffset(2005, 5, 4, 15, 25, 10, Duration::withHours(-4)), Duration::withDays(10));
     // day()
     $this->assertEqual($timespan->day(), 124);
     // dayOfMonth()
     $this->assertEqual($timespan->dayOfMonth(), 4);
     // dayOfWeek()
     $this->assertEqual($timespan->dayOfWeek(), 4);
     // dayOfWeekName()
     $this->assertEqual($timespan->dayOfWeekName(), 'Wednesday');
     // dayOfYear()
     $this->assertEqual($timespan->dayOfYear(), 124);
     // daysInMonth()
     $this->assertEqual($timespan->daysInMonth(), 31);
     // daysInYear()
     $this->assertEqual($timespan->daysInYear(), 365);
     // daysLeftInYear()
     $this->assertEqual($timespan->daysLeftInYear(), 241);
     // duration()
     $temp = Duration::withDays(365);
     $this->assertTrue($temp->isEqualTo($timespan->duration()));
     // end()
     $temp = DateAndTime::withYearMonthDay(2006, 5, 4);
     $temp = $temp->minus(DateAndTime::clockPrecision());
     $this->assertTrue($temp->isEqualTo($timespan->end()));
     // firstDayOfMonth()
     $this->assertEqual($timespan->firstDayOfMonth(), 121);
     // isLeapYear()
     $this->assertEqual($timespan->isLeapYear(), FALSE);
     // julianDayNumber()
     $this->assertEqual($timespan->julianDayNumber(), 2453495);
     // printableString()
     $this->assertEqual($timespan->printableString(), '2005-05-04T00:00:00-04:00D365:00:00:00');
     // startMonth()
     $this->assertEqual($timespan->startMonth(), 5);
     // startMonthAbbreviation()
     $this->assertEqual($timespan->startMonthAbbreviation(), 'May');
     // startMonthIndex()
     $this->assertEqual($timespan->startMonthIndex(), 5);
     // startMonthName()
     $this->assertEqual($timespan->startMonthName(), 'May');
     // start()
     $temp = DateAndTime::withYearMonthDay(2005, 5, 4);
     $this->assertTrue($temp->isEqualTo($timespan->start()));
     // startYear()
     $this->assertEqual($timespan->startYear(), 2005);
 }
コード例 #2
0
ファイル: Timespan.class.php プロジェクト: adamfranco/harmoni
 /**
  * Answer the end of this timespan
  * 
  * @return object DateAndTime
  * @access public
  * @since 5/11/05
  */
 function end()
 {
     $next = $this->next();
     $nextStart = $next->start();
     $obj = $nextStart->minus(DateAndTime::clockPrecision());
     return $obj;
 }