You are here

public function DurationService::convertDateArrayToDateInterval in Duration Field 8.2

Same name and namespace in other branches
  1. 3.0.x src/Service/DurationService.php \Drupal\duration_field\Service\DurationService::convertDateArrayToDateInterval()

Convert a PHP DateInterval object to an ISO 8601 duration string.

Parameters

array $input: An array containing the following keys:

  • y (year)
  • m (month)
  • d (day)
  • h (hour)
  • i (minute)
  • s (second)

Return value

\DateInterval A PHP DateInterval object for the given ISO 8601 duration string.

Throws

Drupal\duration_field\Exception\InvalidDurationException Thrown if $value is not a valid ISO 8601 Duration string.

Overrides DurationServiceInterface::convertDateArrayToDateInterval

File

src/Service/DurationService.php, line 105

Class

DurationService
Provides services for the Duration Field module.

Namespace

Drupal\duration_field\Service

Code

public function convertDateArrayToDateInterval(array $input) {
  $duration_string = $this
    ->convertDateArrayToDurationString($input);
  return $this
    ->getDateIntervalFromDurationString($duration_string);
}