Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

midnight is also an allowed shortcut in crontab #117

Merged
merged 1 commit into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ This library also supports a few macros:
* `@yearly`, `@annually` - Run once a year, midnight, Jan. 1 - `0 0 1 1 *`
* `@monthly` - Run once a month, midnight, first of month - `0 0 1 * *`
* `@weekly` - Run once a week, midnight on Sun - `0 0 * * 0`
* `@daily` - Run once a day, midnight - `0 0 * * *`
* `@daily`, `@midnight` - Run once a day, midnight - `0 0 * * *`
* `@hourly` - Run once an hour, first minute - `0 * * * *`

Requirements
Expand Down
3 changes: 2 additions & 1 deletion src/Cron/CronExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CronExpression
public const DAY = 2;
public const MONTH = 3;
public const WEEKDAY = 4;

/** @deprecated */
public const YEAR = 5;

Expand All @@ -42,6 +42,7 @@ class CronExpression
'@monthly' => '0 0 1 * *',
'@weekly' => '0 0 * * 0',
'@daily' => '0 0 * * *',
'@midnight' => '0 0 * * *',
'@hourly' => '0 * * * *',
];

Expand Down
2 changes: 2 additions & 0 deletions tests/Cron/CronExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function testConstructorRecognizesTemplates(): void
$this->assertSame('0 0 1 1 *', (new CronExpression('@annually'))->getExpression());
$this->assertSame('0 0 1 1 *', (new CronExpression('@yearly'))->getExpression());
$this->assertSame('0 0 * * 0', (new CronExpression('@weekly'))->getExpression());
$this->assertSame('0 0 * * *', (new CronExpression('@daily'))->getExpression());
$this->assertSame('0 0 * * *', (new CronExpression('@midnight'))->getExpression());
}

/**
Expand Down