private function next(LocalDate $date) { $newDayOfMonth = $date->getDayOfMonth() + 1; if ($newDayOfMonth <= $date->getMonth()->length(Year::isLeapYear($date->getYear()))) { return $date->withDayOfMonth($newDayOfMonth); } $date = $date->withDayOfMonth(1); if ($date->getMonth() == Month::DECEMBER()) { $date = $date->withYear($date->getYear() + 1); } return $date->adjust($date->getMonth()->plus(1)); }
/** * Gets the month-of-year field using the {@code Month} enum. * <p> * This method returns the enum {@link Month} for the month. * This avoids confusion as to what {@code int} values mean. * If you need access to the primitive {@code int} value then the enum * provides the {@link Month#getValue() int value}. * * @return Month the month-of-year, not null * @see #getMonthValue() */ public function getMonth() { return $this->date->getMonth(); }