Skip to content

Commit

Permalink
Merge pull request #161 from shrimala/daterange
Browse files Browse the repository at this point in the history
Daterange handler
  • Loading branch information
jhedstrom authored Feb 3, 2018
2 parents 33de911 + cea33fc commit d9461a8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/Drupal/Driver/Fields/Drupal8/DaterangeHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Drupal\Driver\Fields\Drupal8;

/**
* Daterange field handler for Drupal 8.
*/
class DaterangeHandler extends AbstractHandler {

/**
* {@inheritdoc}
*/
public function expand($values) {
$return = [];
foreach ($values as $value) {
$start = str_replace(' ', 'T', $value[0]);
$end = str_replace(' ', 'T', $value[1]);
$return[] = [
'value' => $start,
'end_value' => $end,
];
}
return $return;
}

}

0 comments on commit d9461a8

Please sign in to comment.