public function CarbonInterval::add in Persian Date for Drupal 8 8.4
Add the passed interval to the current instance
Parameters
DateInterval $interval:
Return value
static
File
- src/
Library/ Carbon/ CarbonInterval.php, line 509
Class
- CarbonInterval
- A simple API extension for DateInterval. The implementation provides helpers to handle weeks but only days are saved. Weeks are calculated based on the total days of the current instance.
Namespace
Drupal\persian_date\Library\CarbonCode
public function add(DateInterval $interval) {
$sign = $interval->invert === 1 ? -1 : 1;
if (static::wasCreatedFromDiff($interval)) {
$this->dayz += $interval->days * $sign;
}
else {
$this->years += $interval->y * $sign;
$this->months += $interval->m * $sign;
$this->dayz += $interval->d * $sign;
$this->hours += $interval->h * $sign;
$this->minutes += $interval->i * $sign;
$this->seconds += $interval->s * $sign;
}
return $this;
}