diff --git a/Classes/Domain/Model/Month.php b/Classes/Domain/Model/Month.php index 1bc5102..04a6143 100644 --- a/Classes/Domain/Model/Month.php +++ b/Classes/Domain/Model/Month.php @@ -78,7 +78,7 @@ public function getWeeks(): array while ($currentDay <= $lastDay) { $this->weeks[] = new Week( (int) $currentDay->format('W'), - (int) $currentDay->format('Y') + (int) $currentDay->format('o') ); $currentDay = $currentDay->modify('+7 days'); diff --git a/Classes/Domain/Model/Week.php b/Classes/Domain/Model/Week.php index f02ab53..81e1c65 100644 --- a/Classes/Domain/Model/Week.php +++ b/Classes/Domain/Model/Week.php @@ -80,7 +80,7 @@ public function getPreviousWeek(): Week return new self( (int) $newDay->format('W'), - (int) $newDay->format('Y') + (int) $newDay->format('o') ); } @@ -90,7 +90,7 @@ public function getNextWeek(): Week return new self( (int) $newDay->format('W'), - (int) $newDay->format('Y') + (int) $newDay->format('o') ); } diff --git a/Documentation/Changelog/1.1.1.rst b/Documentation/Changelog/1.1.1.rst new file mode 100644 index 0000000..e837104 --- /dev/null +++ b/Documentation/Changelog/1.1.1.rst @@ -0,0 +1,33 @@ +1.1.1 +===== + +Breaking +-------- + +Nothing + +Features +-------- + +Nothing + +Fixes +----- + +* Fix broken month view if last week of December is in next year. + + The cause was using the wrong character in formatting the year. + We now switch from `Y` to `o` which will work based on the week instead of date. + This is necessary as we provide this year to the week, + and therefore need the year of the week, not day. + +Tasks +----- + +Nothing + +Deprecation +----------- + +Nothing + diff --git a/Tests/Unit/Domain/Model/MonthTest.php b/Tests/Unit/Domain/Model/MonthTest.php index e604516..f214f63 100644 --- a/Tests/Unit/Domain/Model/MonthTest.php +++ b/Tests/Unit/Domain/Model/MonthTest.php @@ -138,6 +138,28 @@ public function returnsAllDaysOfTheFebruaryMonth2021(): void self::assertSame('2021-02-28', $result[27]->getDateTimeInstance()->format('Y-m-d')); } + /** + * @test + */ + public function returnsWeeksIfLastDecemberWeekIsInNextYear(): void + { + $subject = new Month(12, 2024); + + $result = $subject->getWeeks(); + + self::assertCount(6, $result); + + $week = array_pop($result); + $days = $week->getDays(); + self::assertSame('2024-12-30', $days[0]->getDateTimeInstance()->format('Y-m-d')); + self::assertSame('2025-01-05', $days[6]->getDateTimeInstance()->format('Y-m-d')); + + $week = array_pop($result); + $days = $week->getDays(); + self::assertSame('2024-12-23', $days[0]->getDateTimeInstance()->format('Y-m-d')); + self::assertSame('2024-12-29', $days[6]->getDateTimeInstance()->format('Y-m-d')); + } + /** * @test */ diff --git a/ext_emconf.php b/ext_emconf.php index 01b4dca..80d6d14 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -10,7 +10,7 @@ 'state' => 'alpha', 'uploadfolder' => 0, 'clearCacheOnLoad' => 0, - 'version' => '1.1.0', + 'version' => '1.1.1', 'constraints' => [ 'depends' => [ 'typo3' => '*',