Skip to content

Commit

Permalink
Added support for value 7 as sunday
Browse files Browse the repository at this point in the history
- Added the weekday abbreviation 7 which defaults to 0
  • Loading branch information
devtronic committed Nov 10, 2022
1 parent 6581886 commit c430e23
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions src/Content/DateTimeDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class DateTimeDefinition
'thu' => 4,
'fri' => 5,
'sat' => 6,
// Alternative value for sunday
'7' => 0,
];

/** @var DateTimeField[] */
Expand Down
7 changes: 7 additions & 0 deletions tests/Content/CronjobLineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c430e23

Please sign in to comment.