/** * Returns the difference as an array * @param \Jazz\ADateTime $from * @param \Jazz\ADateTime $to */ public function diff(\Jazz\ADateTime $from, \Jazz\ADateTime $to) { $list = $this->getStartEndDates($from, $to); // @var \Jazz\ADateTime $start $start = $list['start']; // @var \Jazz\ADateTime $end $end = $list['end']; // setup hours count $seconds = 0; while ($start->getSecond() != $end->getSecond()) { $start->getSecond(); ++$seconds; } while ($start->getMinute() != $end->getMinute()) { $start->changeMinute(); $seconds += \Jazz\ITime::SECONDS_IN_MINUTE; } while ($start->getHour() != $end->getHour()) { $start->changeHour(); $seconds += \Jazz\ITime::SECONDS_IN_MINUTE * \Jazz\ITime::MINUTES_IN_HOUR; } parent::diff($start, $end); $this->set(self::TYPE_SECOND, $seconds + $this->getDays() * \Jazz\ITime::SECONDS_IN_MINUTE * \Jazz\ITime::MINUTES_IN_HOUR * \Jazz\ITime::HOURS_IN_DAY); $this->set(self::TYPE_DAY, 0); }
/** * Returns the difference as an array * @param \Jazz\ADateTime $from * @param \Jazz\ADateTime $to */ public function diff(\Jazz\ADateTime $from, \Jazz\ADateTime $to) { $list = $this->getStartEndDates($from, $to); // @var \Jazz\ADateTime $start $start = $list['start']; // @var \Jazz\ADateTime $end $end = $list['end']; // setup hours count $hours = 0; while ($start->getHour() != $end->getHour()) { $start->changeHour(); ++$hours; } parent::diff($start, $end); $this->set(self::TYPE_HOUR, $hours + $this->getDays() * \Jazz\ITime::HOURS_IN_DAY); $this->set(self::TYPE_DAY, 0); }
/** * Returns the difference as an array * @param \Jazz\ADateTime $from * @param \Jazz\ADateTime $to */ public function diff(\Jazz\ADateTime $from, \Jazz\ADateTime $to) { parent::diff($from, $to); $this->set(self::TYPE_WEEK, floor($this->getDays() / 7)); $this->set(self::TYPE_DAY, 0); }