예제 #1
0
 /**
  * Testing the getTimeAway() method.
  *
  * @since 2.0
  */
 public function testGetTimeAway()
 {
     $timestamp = new Timestamp();
     $timestamp->setDate($timestamp->getYear() + 1, $timestamp->getMonth(), $timestamp->getDay());
     $this->assertEquals('1 year from now', $timestamp->getTimeAway(), 'testing the getTimeAway() method');
     $timestamp = new Timestamp();
     $timestamp->setDate($timestamp->getYear() - 2, $timestamp->getMonth(), $timestamp->getDay());
     $this->assertEquals('2 years ago', $timestamp->getTimeAway(), 'testing the getTimeAway() method');
 }
예제 #2
0
 /**
  * Calculates and returns the unit of work current duration in seconds.
  *
  * @return int
  *
  * @since 1.0
  */
 public function getUnitDuration()
 {
     self::$logger->debug('>>getUnitDuration()');
     $intStartTime = mktime($this->unitStartTime->getHour(), $this->unitStartTime->getMinute(), $this->unitStartTime->getSecond(), $this->unitStartTime->getMonth(), $this->unitStartTime->getDay(), $this->unitStartTime->getYear());
     $intEndTime = mktime($this->unitEndTime->getHour(), $this->unitEndTime->getMinute(), $this->unitEndTime->getSecond(), $this->unitEndTime->getMonth(), $this->unitEndTime->getDay(), $this->unitEndTime->getYear());
     self::$logger->debug('<<getUnitDuration [' . $intEndTime - $intStartTime . ']');
     return $intEndTime - $intStartTime;
 }