/**
  * Gets the day-of-year field.
  * <p>
  * This method returns the primitive {@code int} value for the day-of-year.
  *
  * @return int the day-of-year, from 1 to 365, or 366 in a leap year
  */
 public function getDayOfYear()
 {
     return $this->date->getDayOfYear();
 }
Exemple #2
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;
 }
 public function setFields(LocalDate $dt)
 {
     if ($dt !== null) {
         $this->fields->put(ChronoField::YEAR(), $dt->getYear());
         $this->fields->put(ChronoField::MONTH_OF_YEAR(), $dt->getMonthValue());
         $this->fields->put(ChronoField::DAY_OF_MONTH(), $dt->getDayOfMonth());
         $this->fields->put(ChronoField::DAY_OF_YEAR(), $dt->getDayOfYear());
         $this->fields->put(ChronoField::DAY_OF_WEEK(), $dt->getDayOfWeek()->getValue());
         $this->fields->put(IsoFields::WEEK_BASED_YEAR(), $dt->getLong(IsoFields::WEEK_BASED_YEAR()));
         $this->fields->put(IsoFields::WEEK_OF_WEEK_BASED_YEAR(), $dt->getLong(IsoFields::WEEK_OF_WEEK_BASED_YEAR()));
     }
 }