You are here

public function CarbonInterval::__set in Persian Date for Drupal 8 8.4

Set a part of the CarbonInterval object

Parameters

string $name:

int $val:

Throws

\InvalidArgumentException

File

src/Library/Carbon/CarbonInterval.php, line 361

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\Carbon

Code

public function __set($name, $val) {
  switch ($name) {
    case 'years':
      $this->y = $val;
      break;
    case 'months':
      $this->m = $val;
      break;
    case 'weeks':
      $this->d = $val * Carbon::DAYS_PER_WEEK;
      break;
    case 'dayz':
      $this->d = $val;
      break;
    case 'hours':
      $this->h = $val;
      break;
    case 'minutes':
      $this->i = $val;
      break;
    case 'seconds':
      $this->s = $val;
      break;
  }
}