From c430e231fac91c40a720141862a117deaae6702b Mon Sep 17 00:00:00 2001 From: Julian Finkler Date: Thu, 10 Nov 2022 07:26:58 +0100 Subject: [PATCH] Added support for value 7 as sunday - Added the weekday abbreviation 7 which defaults to 0 --- CHANGELOG.md | 1 + src/Content/DateTimeDefinition.php | 2 ++ tests/Content/CronjobLineTest.php | 7 +++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80ef404..eea1881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ # Next version Features - Added support for month and weekday abbreviations [PR #4](https://github.com/mintware-de/native-cron/pull/4) +- Added support for value 7 as sunday [PR #5](https://github.com/mintware-de/native-cron/pull/5) # v1.1.2 Fixes: diff --git a/src/Content/DateTimeDefinition.php b/src/Content/DateTimeDefinition.php index be778e9..4a98b81 100644 --- a/src/Content/DateTimeDefinition.php +++ b/src/Content/DateTimeDefinition.php @@ -33,6 +33,8 @@ class DateTimeDefinition 'thu' => 4, 'fri' => 5, 'sat' => 6, + // Alternative value for sunday + '7' => 0, ]; /** @var DateTimeField[] */ diff --git a/tests/Content/CronjobLineTest.php b/tests/Content/CronjobLineTest.php index a91a56a..7f59d61 100644 --- a/tests/Content/CronjobLineTest.php +++ b/tests/Content/CronjobLineTest.php @@ -153,6 +153,13 @@ public function testWeekdayAbbreviations(): void self::assertEquals(5, $cronjobLine->getDateTimeDefinition()->getWeekdays()[0]->getValueFrom()); } + public function testDaySevenShouldBeSunday(): void + { + $line = '* * * * 7 www-data command'; + $cronjobLine = new CronJobLine($line, true); + self::assertEquals(0, $cronjobLine->getDateTimeDefinition()->getWeekdays()[0]->getValueFrom()); + } + private function checkEmptyValues(CronJobLine $cronjobLine): void { $dateTimeDefinition = $cronjobLine->getDateTimeDefinition();