From 128d365a72dbf456ca98ae1b5c7ab7f740bf14bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 3 Apr 2025 17:47:08 +0200 Subject: [PATCH] Convert Rolling date using the clock instead of the built-in pivot date --- .../Service/RollingDate/RollingDateConverter.php | 8 ++------ .../Tests/Services/RollingDate/RollingDateTest.php | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php index 6283bc1d1..c2633cebb 100644 --- a/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php +++ b/src/Bundle/ChillMainBundle/Service/RollingDate/RollingDateConverter.php @@ -15,11 +15,7 @@ use Symfony\Component\Clock\ClockInterface; final readonly class RollingDateConverter implements RollingDateConverterInterface { - - function __construct(private readonly ClockInterface $clock) - { - - } + public function __construct(private readonly ClockInterface $clock) {} public function convert(?RollingDate $rollingDate): ?\DateTimeImmutable { @@ -38,7 +34,7 @@ final readonly class RollingDateConverter implements RollingDateConverterInterfa return $this->toBeginOfMonth(($rollingDate->getPivotDate() ?? $this->clock->now())->sub(new \DateInterval('P1M'))); case RollingDate::T_QUARTER_CURRENT_START: - return $this->toBeginOfQuarter($rollingDate->getPivotDate()?? $this->clock->now()); + return $this->toBeginOfQuarter($rollingDate->getPivotDate() ?? $this->clock->now()); case RollingDate::T_QUARTER_NEXT_START: return $this->toBeginOfQuarter(($rollingDate->getPivotDate() ?? $this->clock->now())->add(new \DateInterval('P3M'))); diff --git a/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateTest.php b/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateTest.php index bd80e9ae8..a700fc642 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/RollingDate/RollingDateTest.php @@ -42,5 +42,4 @@ class RollingDateTest extends TestCase self::assertEquals($fixed, $actual->getFixedDate()); self::assertEquals($date->getPivotDate()?->getTimestamp(), $actual->getPivotDate()?->getTimestamp()); } - }