You are here

public function Carbon::addMonthsNoOverflow in Persian Date for Drupal 8 8.4

Add months without overflowing to the instance. Positive $value travels forward while negative $value travels into the past.

Parameters

int $value:

Return value

static

3 calls to Carbon::addMonthsNoOverflow()
Carbon::addMonthNoOverflow in src/Library/Carbon/Carbon.php
Add a month with no overflow to the instance
Carbon::addMonths in src/Library/Carbon/Carbon.php
Add months to the instance. Positive $value travels forward while negative $value travels into the past.
Carbon::subMonthsNoOverflow in src/Library/Carbon/Carbon.php
Remove months with no overflow from the instance

File

src/Library/Carbon/Carbon.php, line 2218

Class

Carbon
A simple API extension for DateTime

Namespace

Drupal\persian_date\Library\Carbon

Code

public function addMonthsNoOverflow($value) {
  $day = $this->day;
  $this
    ->modify((int) $value . ' month');
  if ($day !== $this->day) {
    $this
      ->modify('last day of previous month');
  }
  return $this;
}