示例#1
0
 /**
  * Converts this to a transition rule.
  *
  * @param ZoneOffset $standardOffset the active standard offset, not null
  * @param int $savingsBeforeSecs the active savings before the transition in seconds
  * @return ZoneOffsetTransitionRule the transition, not null
  */
 function toTransitionRule(ZoneOffset $standardOffset, $savingsBeforeSecs)
 {
     // optimize stored format
     if ($this->dayOfMonthIndicator < 0) {
         if ($this->month != Month::FEBRUARY()) {
             $this->dayOfMonthIndicator = $this->month->maxLength() - 6;
         }
     }
     if ($this->timeEndOfDay && $this->dayOfMonthIndicator > 0 && ($this->dayOfMonthIndicator === 28 && $this->month == Month::FEBRUARY()) == false) {
         $date = LocalDate::ofMonth(2004, $this->month, $this->dayOfMonthIndicator)->plusDays(1);
         // leap-year
         $this->month = $date->getMonth();
         $this->dayOfMonthIndicator = $date->getDayOfMonth();
         if ($this->dayOfWeek !== null) {
             $this->dayOfWeek = $this->dayOfWeek->plus(1);
         }
         $this->timeEndOfDay = false;
     }
     // build rule
     $trans = $this->toTransition($standardOffset, $savingsBeforeSecs);
     return ZoneOffsetTransitionRule::of($this->month, $this->dayOfMonthIndicator, $this->dayOfWeek, $this->time, $this->timeEndOfDay, $this->timeDefinition, $standardOffset, $trans->getOffsetBefore(), $trans->getOffsetAfter());
 }