You are here

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

Set a part of the Carbon object

Parameters

string $name:

string|int|\DateTimeZone $value:

Throws

\InvalidArgumentException

File

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

Class

Carbon
A simple API extension for DateTime

Namespace

Drupal\persian_date\Library\Carbon

Code

public function __set($name, $value) {
  switch ($name) {
    case 'year':
    case 'month':
    case 'day':
    case 'hour':
    case 'minute':
    case 'second':
      list($year, $month, $day, $hour, $minute, $second) = explode('-', $this
        ->format('Y-n-j-G-i-s'));
      ${$name} = $value;
      $this
        ->setDateTime($year, $month, $day, $hour, $minute, $second);
      break;
    case 'timestamp':
      parent::setTimestamp($value);
      break;
    case 'timezone':
    case 'tz':
      $this
        ->setTimezone($value);
      break;
    default:
      throw new InvalidArgumentException(sprintf("Unknown setter '%s'", $name));
  }
}