예제 #1
0
 public function testGetSetEndDate()
 {
     $object = new Task();
     $value = time();
     $this->assertEquals('', $object->getEndDate());
     $this->assertInstanceOf('PhpOffice\\PhpProject\\Task', $object->setEndDate());
     $this->assertEquals($value, $object->getEndDate());
     $this->assertInstanceOf('PhpOffice\\PhpProject\\Task', $object->setEndDate($value));
     $this->assertEquals($value, $object->getEndDate());
     $this->assertInstanceOf('PhpOffice\\PhpProject\\Task', $object->setEndDate((string) $value));
     $this->assertEquals($value, $object->getEndDate());
     $this->assertInstanceOf('PhpOffice\\PhpProject\\Task', $object->setEndDate('2014-12-05 00:05:00'));
     $this->assertEquals(strtotime('2014-12-05 00:05:00'), $object->getEndDate());
 }
예제 #2
0
 /**
  * Permits to clean a task
  * - If the duration is not filled, but the end date is, we calculate it.
  * - If the end date is not filled, but the duration is, we calculate it.
  * @param PHPProject_Task $oTask
  */
 private function sanitizeTask(Task $oTask)
 {
     $pDuration = $oTask->getDuration();
     $pEndDate = $oTask->getEndDate();
     $pStartDate = $oTask->getStartDate();
     if (is_null($pDuration) && !is_null($pEndDate)) {
         $iTimeDiff = $pEndDate - $pStartDate;
         $iNumDays = $iTimeDiff / 60 / 60 / 24;
         $oTask->setDuration($iNumDays + 1);
     } elseif (!is_null($pDuration) && is_null($pEndDate)) {
         $oTask->setEndDate($pStartDate + $pDuration * 24 * 60 * 60);
     }
 }