From c5cb8030734250b963331fe7f8215584140fd4f9 Mon Sep 17 00:00:00 2001 From: Sebastian Thulin Date: Mon, 10 Feb 2025 11:42:42 +0100 Subject: [PATCH] fix: handle date as array (#517) * fix: handle date as array * fix: move to controller. --------- Co-authored-by: Sebastian Thulin --- source/php/Component/Segment/Segment.php | 14 ++++++++++++++ .../Component/Segment/components/content.blade.php | 6 +----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/source/php/Component/Segment/Segment.php b/source/php/Component/Segment/Segment.php index 2b2b0a96..398d9ca7 100644 --- a/source/php/Component/Segment/Segment.php +++ b/source/php/Component/Segment/Segment.php @@ -113,6 +113,20 @@ public function init() if(!$hasImage && !$hasPlaceholder) { $this->data['classList'][] = $this->getBaseClass('no-image', true); } + + //Handle date data + if ($date && !is_array($date)) { + $this->data['date'] = [ + 'timestamp' => $date, + 'action' => 'formatDate' + ]; + } + + if ($date) { + $this->data['date']['classList'] ??= []; + $this->data['date']['classList'][] = $this->getBaseClass('date'); + } + } /** diff --git a/source/php/Component/Segment/components/content.blade.php b/source/php/Component/Segment/components/content.blade.php index 1b8dec67..f8b1f1e4 100644 --- a/source/php/Component/Segment/components/content.blade.php +++ b/source/php/Component/Segment/components/content.blade.php @@ -60,11 +60,7 @@ @endif @if ($date) - @date([ - 'action' => false, - 'timestamp' => $date, - 'classList' => [$baseClass . '__date'] - ]) + @date($date) @enddate @endif