Пример #1
0
 private function resolveWoY(FieldValues $fieldValues, Chronology $chrono, $year, $woy, $localDow, ResolverStyle $resolverStyle)
 {
     $date = $chrono->date($year, 1, 1);
     if ($resolverStyle == ResolverStyle::LENIENT()) {
         $weeks = Math::subtractExact($woy, $this->localizedWeekOfYear($date));
         $days = $localDow - $this->localizedDayOfWeek($date);
         // safe from overflow
         $date = $date->plus(Math::addExact(Math::multiplyExact($weeks, 7), $days), ChronoUnit::DAYS());
     } else {
         $womInt = $this->range->checkValidIntValue($woy, $this);
         // validate
         $weeks = (int) ($womInt - $this->localizedWeekOfYear($date));
         // safe from overflow
         $days = $localDow - $this->localizedDayOfWeek($date);
         // safe from overflow
         $date = $date->plus($weeks * 7 + $days, ChronoUnit::DAYS());
         if ($resolverStyle == ResolverStyle::STRICT() && $date->getLong(CF::YEAR()) !== $year) {
             throw new DateTimeException("Strict mode rejected resolved date as it is in a different year");
         }
     }
     $fieldValues->remove($this);
     $fieldValues->remove(CF::YEAR());
     $fieldValues->remove(CF::DAY_OF_WEEK());
     return $date;
 }