public function Carbon::__get in Persian Date for Drupal 8 8.4
Get a part of the Carbon object
Parameters
string $name:
Return value
string|int|\DateTimeZone
Throws
\InvalidArgumentException
1 call to Carbon::__get()
- Carbon::__isset in src/
Library/ Carbon/ Carbon.php - Check if an attribute exists on the object
File
- src/
Library/ Carbon/ Carbon.php, line 653
Class
- Carbon
- A simple API extension for DateTime
Namespace
Drupal\persian_date\Library\CarbonCode
public function __get($name) {
switch (true) {
case array_key_exists($name, $formats = array(
'year' => 'Y',
'yearIso' => 'o',
'month' => 'n',
'day' => 'j',
'hour' => 'G',
'minute' => 'i',
'second' => 's',
'micro' => 'u',
'dayOfWeek' => 'w',
'dayOfYear' => 'z',
'weekOfYear' => 'W',
'daysInMonth' => 't',
'timestamp' => 'U',
)):
return (int) $this
->format($formats[$name]);
case $name === 'weekOfMonth':
return (int) ceil($this->day / static::DAYS_PER_WEEK);
case $name === 'age':
return $this
->diffInYears();
case $name === 'quarter':
return (int) ceil($this->month / static::MONTHS_PER_QUARTER);
case $name === 'offset':
return $this
->getOffset();
case $name === 'offsetHours':
return $this
->getOffset() / static::SECONDS_PER_MINUTE / static::MINUTES_PER_HOUR;
case $name === 'dst':
return $this
->format('I') === '1';
case $name === 'local':
return $this
->getOffset() === $this
->copy()
->setTimezone(date_default_timezone_get())
->getOffset();
case $name === 'utc':
return $this
->getOffset() === 0;
case $name === 'timezone' || $name === 'tz':
return $this
->getTimezone();
case $name === 'timezoneName' || $name === 'tzName':
return $this
->getTimezone()
->getName();
default:
throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name));
}
}