Beispiel #1
0
 /**
  * @internal
  * @param LocalDate $date
  * @return int
  */
 public static function getWeekBasedYear(LocalDate $date)
 {
     $year = $date->getYear();
     $doy = $date->getDayOfYear();
     if ($doy <= 3) {
         $dow = $date->getDayOfWeek()->getValue() - 1;
         if ($doy - $dow < -2) {
             $year--;
         }
     } else {
         if ($doy >= 363) {
             $dow = $date->getDayOfWeek()->getValue() - 1;
             $doy = $doy - 363 - ($date->isLeapYear() ? 1 : 0);
             if ($doy - $dow >= 0) {
                 $year++;
             }
         }
     }
     return $year;
 }