Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Drupal/Driver/Fields/Drupal8/TimeHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Drupal\Driver\Fields\Drupal8;

/**
* Time field handler for Drupal 8.
*/
class TimeHandler extends AbstractHandler {

/**
* {@inheritdoc}
*/
public function expand($values) {
$values = array_map(function ($value) {
// Value is numeric so it is safe to assume we have the seconds passed in
// the storage format (seconds past midnight).
if (is_numeric($value)) {
return $value;
}

// Support anything that can be passed to strtotime.
$midnight = strtotime('today midnight');
return strtotime($value) - $midnight;;
}, $values);

return $values;
}
}