/** * Validates that this window is after the previous one. * * @param TZWindow $previous the previous window, not null * @throws \LogicException if the window order is invalid */ function validateWindowOrder(TZWindow $previous) { if ($this->windowEnd->isBefore($previous->windowEnd)) { throw new \LogicException("Windows must be added in date-time order: " . $this->windowEnd . " < " . $previous->windowEnd); } }
/** * Finds the offset info for a local date-time and transition. * * @param LocalDateTime $dt the date-time, not null * @param ZoneOffsetTransition $trans the transition, not null * @return ZoneOffsetTransition|ZoneOffset the offset info, not null */ private function findOffsetInfo(LocalDateTime $dt, ZoneOffsetTransition $trans) { $localTransition = $trans->getDateTimeBefore(); if ($trans->isGap()) { if ($dt->isBefore($localTransition)) { return $trans->getOffsetBefore(); } if ($dt->isBefore($trans->getDateTimeAfter())) { return $trans; } else { return $trans->getOffsetAfter(); } } else { if ($dt->isBefore($localTransition) == false) { return $trans->getOffsetAfter(); } if ($dt->isBefore($trans->getDateTimeAfter())) { return $trans->getOffsetBefore(); } else { return $trans; } } }