Skip to content
Snippets Groups Projects
Commit d827cc0a authored by Ivan Doroshenko's avatar Ivan Doroshenko Committed by Owen Bush
Browse files

Issue #3283128 by Matroskeen, owenbush: Use date.formatter service to format date values

parent 0eaad340
No related branches found
Tags 2.0.0-beta3
No related merge requests found
......@@ -4,6 +4,7 @@ namespace Drupal\recurring_events\Plugin\views\field;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Field handler to show the start date of an event series.
......@@ -14,6 +15,22 @@ use Drupal\views\ResultRow;
*/
class EventSeriesStartDate extends FieldPluginBase {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);
$instance->dateFormatter = $container->get('date.formatter');
return $instance;
}
/**
* {@inheritdoc}
*/
......@@ -33,7 +50,7 @@ class EventSeriesStartDate extends FieldPluginBase {
if (!empty($event_start)) {
$format = \Drupal::config('recurring_events.eventseries.config')->get('date_format');
$start_date = $event_start->setTimezone($timezone)->format($format);
$start_date = $this->dateFormatter->format($event_start->getTimestamp(), 'custom', $format, $timezone->getName());
}
return $start_date;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment