0001-patched-DateRangeFormatter-to-localized-single-date.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From f26202ce5871ee393f86cc4afd79c3b4368c453a Mon Sep 17 00:00:00 2001
  2. From: Bachir Soussi Chiadmi <bachir@figureslibres.io>
  3. Date: Tue, 15 May 2018 13:54:08 +0200
  4. Subject: [PATCH] patched DateRangeFormatter to localized single date
  5. ---
  6. .../FieldFormatter/DateRangeFormatterRangeFormatter.php | 5 +++--
  7. 1 file changed, 3 insertions(+), 2 deletions(-)
  8. diff --git a/sites/all/modules/contrib/fields/date_range_formatter/src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php b/sites/all/modules/contrib/fields/date_range_formatter/src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php
  9. index 26def1be..a7df140d 100644
  10. --- a/sites/all/modules/contrib/fields/date_range_formatter/src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php
  11. +++ b/sites/all/modules/contrib/fields/date_range_formatter/src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php
  12. @@ -63,7 +63,6 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
  13. if (date('d.m.Y', $start_date) === date('d.m.Y', $end_date)) {
  14. $format = $this->getSetting('one_day');
  15. }
  16. -
  17. $date_str = format_date($start_date, 'custom', preg_replace('/\{([a-zA-Z])\}/', '{\\\$1}', t($format)));
  18. $matches = array();
  19. if (preg_match_all('/\{([a-zA-Z])\}/', $date_str, $matches)) {
  20. @@ -75,7 +74,9 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
  21. }
  22. else {
  23. - $elements[$delta] = ['#markup' => date($this->getSetting('one_day'), $start_date)];
  24. + $format = $this->getSetting('one_day');
  25. + $date_str = format_date($start_date, 'custom', $format);
  26. + $elements[$delta] = ['#markup' => $date_str];
  27. }
  28. }
  29. }
  30. --
  31. 2.17.0