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

Add additional cron hash aliases #61

Merged
merged 3 commits into from
Apr 13, 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
4 changes: 0 additions & 4 deletions .scrutinizer.yml

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# The ScheduleBundle

[![CI](https://github.com/zenstruck/schedule-bundle/workflows/CI/badge.svg)](https://github.com/zenstruck/schedule-bundle/actions?query=workflow%3ACI)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/zenstruck/schedule-bundle/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/zenstruck/schedule-bundle/?branch=master)
[![Code Coverage](https://codecov.io/gh/zenstruck/schedule-bundle/branch/master/graph/badge.svg?token=SZE54O8YST)](https://codecov.io/gh/zenstruck/schedule-bundle)
[![Latest Version](https://img.shields.io/packagist/v/zenstruck/schedule-bundle.svg)](https://packagist.org/packages/zenstruck/schedule-bundle)
[![Total Downloads](https://img.shields.io/packagist/dt/zenstruck/schedule-bundle.svg)](https://packagist.org/packages/zenstruck/schedule-bundle)
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
],
"require": {
"php": ">=7.2",
"dragonmantank/cron-expression": "^2.3",
"dragonmantank/cron-expression": "^2.3|^3.0",
"symfony/console": "^4.0|^5.0|^6.0",
"symfony/dependency-injection": "^4.0|^5.0|^6.0",
"symfony/event-dispatcher": "^4.0|^5.0|^6.0",
"symfony/http-kernel": "^4.0|^5.0|^6.0",
"symfony/polyfill-php80": "^1.15"
},
"require-dev": {
"lorisleiva/cron-translator": "^0.1.0",
"lorisleiva/cron-translator": "^0.1.0|^0.3.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"phpstan/phpstan": "^1.4",
"psr/log": "^1.1",
"symfony/http-client": "^4.3|^5.0|^6.0",
"symfony/lock": "^4.4|^5.0|^6.0",
"symfony/mailer": "^4.4|^5.0|^6.0",
"symfony/messenger": "^4.4|^5.0|^6.0",
"symfony/phpunit-bridge": "^5.3",
"symfony/phpunit-bridge": "^6.0",
"symfony/process": "^4.2|^5.0|^6.0"
},
"suggest": {
Expand Down
22 changes: 13 additions & 9 deletions doc/define-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,19 @@ is to account for February which has a minimum of 28 days.*

The following *hash* aliases are provided:

| Alias | Converts to |
| ----------- | ---------------------------------------------------------------------- |
| `#hourly` | `# * * * *` (at some minute every hour) |
| `#daily` | `# # * * *` (at some time every day) |
| `#midnight` | `# #(0-2) * * *` (at some time between midnight and 2:59am, every day) |
| `#weekly` | `# # * * #` (at some time every week) |
| `#monthly` | `# # # * *` (at some time on some day, once per month) |
| `#annually` | `# # # # *` (at some time on some day, once per year) |
| `#yearly` | `# # # # *` (at some time on some day, once per year) |
| Alias | Converts to |
|----------------------|------------------------------------------------------------------------|
| `#hourly` | `# * * * *` (at some minute every hour) |
| `#daily` | `# # * * *` (at some time every day) |
| `#midnight` | `# #(0-2) * * *` (at some time between midnight and 2:59am, every day) |
| `#weekly` | `# # * * #` (at some time every week) |
| `#weekly@midnight` | `# #(0-2) * * #` (at `#midnight` one day every week) |
| `#monthly` | `# # # * *` (at some time on some day, once per month) |
| `#monthly@midnight` | `# #(0-2) # * *` (at `#midnight` on some day, once per month) |
| `#annually` | `# # # # *` (at some time on some day, once per year) |
| `#annually@midnight` | `# #(0-2) # # *` (at `#midnight` on some day, once per year) |
| `#yearly` | _alias for `#annually`_ |
| `#yearly@midnight` | _alias for `#annually@midnight`_ |

**Define in [PHP](define-schedule.md#schedulebuilder-service):**

Expand Down
4 changes: 4 additions & 0 deletions src/Schedule/CronExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ final class CronExpression
'#hourly' => '# * * * *',
'#daily' => '# # * * *',
'#weekly' => '# # * * #',
'#weekly@midnight' => '# #(0-2) * * #',
'#monthly' => '# # # * *',
'#monthly@midnight' => '# #(0-2) # * *',
'#annually' => '# # # # *',
'#annually@midnight' => '# #(0-2) # # *',
'#yearly' => '# # # # *',
'#yearly@midnight' => '# #(0-2) # # *',
'#midnight' => '# #(0-2) * * *',
];

Expand Down
4 changes: 4 additions & 0 deletions tests/Schedule/CronExpressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ public static function hashedExpressionProvider(): array
['#hourly', '56 * * * *'],
['#daily', '56 20 * * *'],
['#weekly', '56 20 * * 0'],
['#weekly@midnight', '56 2 * * 0'],
['#monthly', '56 20 1 * *'],
['#monthly@midnight', '56 2 1 * *'],
['#yearly', '56 20 1 9 *'],
['#yearly@midnight', '56 2 1 9 *'],
['#annually', '56 20 1 9 *'],
['#annually@midnight', '56 2 1 9 *'],
['#midnight', '56 2 * * *'],
['#(1-15) * * * *', '12 * * * *'],
['#(1-15) * * * #(3-5)', '12 * * * 5'],
Expand Down