public static function CarbonInterval::instance in Persian Date for Drupal 8 8.4
Create a CarbonInterval instance from a DateInterval one. Can not instance DateInterval objects created from DateTime::diff() as you can't externally set the $days field.
Parameters
DateInterval $di:
Return value
static
Throws
\InvalidArgumentException
File
- src/
Library/ Carbon/ CarbonInterval.php, line 227
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 static function instance(DateInterval $di) {
if (static::wasCreatedFromDiff($di)) {
throw new InvalidArgumentException('Can not instance a DateInterval object created from DateTime::diff().');
}
$instance = new static($di->y, $di->m, 0, $di->d, $di->h, $di->i, $di->s);
$instance->invert = $di->invert;
$instance->days = $di->days;
return $instance;
}