function DurationIso8601::getDuration

Returns the duration.

Return value

\DateInterval|null A DateInterval object or NULL if there is no duration.

Overrides DurationInterface::getDuration

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/DurationIso8601.php, line 22

Class

DurationIso8601
The duration ISO8601 data type.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function getDuration() {
  if ($this->value) {
    // @todo: Add support for negative intervals on top of the DateInterval
    // constructor.
    return new \DateInterval($this->value);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.