Esempio n. 1
0
 /**
  * @param ZoneRulesBuilder $bld
  * @param TZDBRule[][] $rules
  * @return ZoneRulesBuilder
  * @throws IllegalArgumentException
  */
 public function addToBuilder(ZoneRulesBuilder $bld, array $rules)
 {
     if ($this->year !== Year::MAX_VALUE) {
         $bld->addWindow($this->standardOffset, $this->toDateTime($this->year), $this->timeDefinition);
     } else {
         $bld->addWindowForever($this->standardOffset);
     }
     if ($this->fixedSavingsSecs !== null) {
         $bld->setFixedSavingsToWindow($this->fixedSavingsSecs);
     } else {
         $tzdbRules = @$rules[$this->savingsRule];
         if ($tzdbRules === null) {
             throw new IllegalArgumentException("Rule not found: " . $this->savingsRule);
         }
         foreach ($tzdbRules as $tzdbRule) {
             $tzdbRule->addToBuilder($bld);
         }
     }
     return $bld;
 }
Esempio n. 2
0
 /**
  * Converts this to a transition.
  *
  * @param ZoneOffset $standardOffset the active standard offset, not null
  * @param int $savingsBeforeSecs the active savings in seconds
  * @return ZoneOffsetTransition the transition, not null
  */
 function toTransition(ZoneOffset $standardOffset, $savingsBeforeSecs)
 {
     // copy of code in ZoneOffsetTransitionRule to avoid infinite loop
     $date = $this->toLocalDate();
     $date = ZoneRulesBuilder::deduplicate($date);
     $ldt = ZoneRulesBuilder::deduplicate(LocalDateTime::ofDateAndTime($date, $this->time));
     /** @var ZoneOffset $wallOffset */
     $wallOffset = ZoneRulesBuilder::deduplicate(ZoneOffset::ofTotalSeconds($standardOffset->getTotalSeconds() + $savingsBeforeSecs));
     $dt = ZoneRulesBuilder::deduplicate($this->timeDefinition->createDateTime($ldt, $standardOffset, $wallOffset));
     $offsetAfter = ZoneRulesBuilder::deduplicate(ZoneOffset::ofTotalSeconds($standardOffset->getTotalSeconds() + $this->savingAmountSecs));
     return new ZoneOffsetTransition($dt, $wallOffset, $offsetAfter);
 }