lorisleiva / cron-translator Goto Github PK
View Code? Open in Web Editor NEW⏰️ Makes CRON expressions human-readable
License: MIT License
⏰️ Makes CRON expressions human-readable
License: MIT License
I get the parsing error Failed to parse the following CRON expression: 0 9 1-7,15-21 * 1
A good example is a bi-weekly cron expression which is also fairly common => 0 9 1-7,15-21 * 1 see it here crontab.guru .
I want to contribute with Romanian translation
ro.zip
Hi, there is such a cron:
*/15 0-8,21-23 * * *
And i get the error:
Failed to parse the following CRON expression: */15 0-8,21-23 * * * {"userId":205,"exception":"[object] (Lorisleiva\CronTranslator\CronParsingException(code: 0): Failed to parse the following CRON expression: */15 0-8,21-23 * * * at /var/www/vendor/lorisleiva/cron-translator/src/CronTranslator.php:33)
How to fix it?
On https://crontab.guru/ such this cron is recognized...
Hi
Would the @reboot and other be supported in future?
string meaning @reboot Run once, at startup. @yearly Run once a year, "0 0 1 1 *". @annually (sames as @yearly) @monthly Run once a month, "0 0 1 * *". @weekly Run once a week, "0 0 * * 0". @daily Run once a day, "0 0 * * *". @midnight (same as @daily) @hourly Run once an hour, "0 * * * *".
Hi @lorisleiva
Thank you for the package!
I'm wondering, would it be possible to add translations support?
Any number value passed to first field gives translation "Once an hour".
Example: 756 * * * *, 659 * * * * ...
That is wrong.
It should only accept numbers 0-59 and output should be 'At minute 0' - 'At minute 59' .
While this may seem human readable it actually simplifies it too much.
1-5
for hours does not mean 5 times a day
as that would imply its spread out over the whole 24 hours ie 4,8,12,16,20,0
. Same applies for the mins/days/months etc. Its can actually be very misleading.
0 1-5 * * *
would be better represented as Hourly between 1-5am
0 1-5,12 * * *
would be better represented as Hourly between 1-5am/12pm
0 1-5,12 * * *
would be better represented as Hourly between 1-5am/12pm
CronTranslator::translate('0 1-5 * * *'); // => 5 times a day
CronTranslator::translate('0 1 1-5 * *'); // => 5 days a month at 1:00am
Is only an idea but can be interesting to add two methods: one to validate valid(): bool and one to determinate the next and previus run. What do you think?
Is there a way to find if the specified command is valid, before translating it?
Hi,
I think there is a mistake in one of the french translation of the crons. When a cron expression return "times per day", it says two times the word "fois" in french.
Example :
This cron expression : 00 2,8,14,20 * * * returns "4 fois fois par jour" when it should be "4 fois par jour"
I think the mistake is with your "times" array in lang/fr/times.php :
return [ 'default' => ':number fois', ];
Mixed with your "times_per_day" key in the "hours" array in lang/fr/fields.php :
'times_per_day' => ':times fois par jour',
<?php
class DaysOfMonthField extends Field {
public $position = 2;
/**
* @throws CronParsingException
*/
public function translateEvery() {
**if ($this->expression->weekday->hasType('Once')) {**
return $this->lang('days_of_week.every', [
'weekday' => $this->expression->weekday->format(),
]);
}
return $this->lang('days_of_month.every');
}
There are many PR's open that are just translations, I think these people deserve a reaction on their effort to improve this library.
Can I help somehow to check (and maybe pull) the PR's.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.