/**
  * Map the field range to a week range of a week year.
  * @param TemporalAccessor $temporal the temporal
  * @return ValueRange the ValueRange with the range adjusted to weeks.
  */
 private function rangeWeekOfWeekBasedYear(TemporalAccessor $temporal)
 {
     if (!$temporal->isSupported(CF::DAY_OF_YEAR())) {
         return self::WEEK_OF_YEAR_RANGE();
     }
     $dow = $this->localizedDayOfWeek($temporal);
     $doy = $temporal->get(CF::DAY_OF_YEAR());
     $offset = $this->startOfWeekOffset($doy, $dow);
     $week = $this->computeWeek($offset, $doy);
     if ($week === 0) {
         // Day is in end of week of previous year
         // Recompute from the last day of the previous year
         $date = AbstractChronology::from($temporal)->dateFrom($temporal);
         $date = $date->minus($doy + 7, ChronoUnit::DAYS());
         // Back down into previous year
         return $this->rangeWeekOfWeekBasedYear($date);
     }
     // Check if day of year is in partial week associated with next year
     $dayRange = $temporal->range(CF::DAY_OF_YEAR());
     $yearLen = $dayRange->getMaximum();
     $newYearWeek = $this->computeWeek($offset, $yearLen + $this->weekDef->getMinimalDaysInFirstWeek());
     if ($week >= $newYearWeek) {
         // Overlaps with weeks of following year; recompute from a week in following year
         $date = AbstractChronology::from($temporal)->dateFrom($temporal);
         $date = $date->plus($yearLen - $doy + 1 + 7, ChronoUnit::DAYS());
         return $this->rangeWeekOfWeekBasedYear($date);
     }
     return ValueRange::of(1, $newYearWeek - 1);
 }