Пример #1
0
 function plusMonths($months)
 {
     return $this->withDate($this->isoDate->plusMonths($months));
 }
Пример #2
0
 /**
  * Returns a copy of this {@code LocalDateTime} with the specified number of months added.
  * <p>
  * This method adds the specified amount to the months field in three steps:
  * <ol>
  * <li>Add the input months to the month-of-year field</li>
  * <li>Check if the resulting date would be invalid</li>
  * <li>Adjust the day-of-month to the last valid day if necessary</li>
  * </ol>
  * <p>
  * For example, 2007-03-31 plus one month would result in the invalid date
  * 2007-04-31. Instead of returning an invalid result, the last valid day
  * of the month, 2007-04-30, is selected instead.
  * <p>
  * This instance is immutable and unaffected by this method call.
  *
  * @param int $months the months to add, may be negative
  * @return LocalDateTime a {@code LocalDateTime} based on this date-time with the months added, not null
  * @throws DateTimeException if the result exceeds the supported date range
  */
 public function plusMonths($months)
 {
     $newDate = $this->date->plusMonths($months);
     return $this->_with($newDate, $this->time);
 }