azza-bazoo / prettycron Goto Github PK
View Code? Open in Web Editor NEWDisplay cron runspecs in human-readable format
License: GNU Lesser General Public License v3.0
Display cron runspecs in human-readable format
License: GNU Lesser General Public License v3.0
Hi,
I'm getting a very strange issue.
If I use prettyCron.toString( "0 * * * *"), everything is fine and I get "Every hour, on the hour"
If I use prettyCron.toString( "15 * * * *"), I'm expecting something like "Every hour, on the minute 15", but I get this error in the javascript console:
TypeError: Cannot read property 'ordinal' of undefined at numberList (prettycron.js:38:30)
Could you help? Thanks !!!
using an expression like:
*/2 * * * *
results in:
Every 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56 and 58th minute past every hour
the result shoud be more readable, like:
"every other minute" for */2 * * * *
or
"every forth hour" for 0 */4 * * *
Hi
I am a member of CDNJS and the one who is in charge of adding prettycron to CDNJS according to the request cdnjs/cdnjs#10567.
I found that there is v0.11.0 on GitHub, is it possible for you to release it on npm?
It will help me use npm as the source to let prettycron be more compete on CDNJS ๐
Thank you!
If date and day are both specified, they should be treated as or. E.g. in the example below, the cron string means "every minute of the first of January and also every minute of every Monday in January". The next run should be 1/1/2021 (I'm less concerned about the 12/31 it's returning, pretty sure that's because it's converting from 1/1 UTC to my local timezone)
prettyCron.getNext("* * 1 1 1")
=> "12/31/2023"
The description's also not great
prettyCron.toString("* * 1 1 1")
=> "Every minute on the 1st and every Mon in Jan"
For me it's kind of inconsistent to have toString
returning a 24h format and getNext
returning 12h format. I think it would be better to stick with only the more universal AM/PM format.
Would be neat if prettycron would support keywords such as @daily
and @reboot
.
https://en.wikipedia.org/wiki/Cron#Nonstandard_predefined_scheduling_definitions
As I write this, I have a cron set to run at 7:00am Eastern Time (currently GMT-5). The cron actually runs at the specified time, but the human readable form says it's not going to run again until 3:00am tomorrow. It seems prettycron is not using the local system's timezone information. I did not see anything in the documentation to set this.
Added some additional information to the output:
Runs Tomorrow at 3:00 AM [0 7 * * *], locale is en, time is 07:09:30, timezone offset is 240
Calling toString()
against this expression 0 0/15 * * * ?
results in 00:00 and 15:00 every day
, while the correct description should be something like: every 15 minutes
.
Check here for comparison of the output of another similar (.NET) library.
When using create-react-app I get the following error at compile time:
Module not found: Can't resolve './later-cov' in 'C:\node_modules\later'
This can be temporarily resolved by changing line 26 from this:
var later = require('later');
to this:
var later = require('later/later.js');
This doesn't actually work with the latest version of webpack, I had to fork prettycron
and later
similar to @RickCarlino here bunkat/later#155 (comment)
Example:
Cron expression: 5 5 20 1 3
Human readable: 05:05 on the 20th and every Wed in Jan
This will only run on the 20th of January that falls on a Wednesday. Not every Wednesday in January.
Hello Team,
We would like to use it in our Angular project. Is there any way we can use this in Angular 12?
Where x
in a cron expression x * * * *
is, for example, 2, giving:
2 * * * *
- then prettycron translates this as:
Every 2nd minute past every hour
In English, this translation means :02, :04, :06, . But that's not what the cron expression actually says.
The cron expression means to run "At one min past every hour": See http://www.unixgeeks.org/security/newbie/unix/cron-1.html , referenced here: https://en.wikipedia.org/wiki/Cron#References .
This issue makes prettycron unusable for many use-cases.
I get the error from,
var toString = function(cronspec, sixth) {
var schedule = later.parse.cron(cronspec, sixth);
return scheduleToSentence(schedule['schedules'][0], sixth);
};
The cron 30 10 * * 0 which means run at 10:30 every sunday is actually returned as "00:00 on Mon" by getPrettyCron().
var cron = "30 10 * * 0";
var schedule = later.parse.cron(cron, false);
console.log(getPrettyCron(schedule['schedules'][0]));
When cron expression specifies to run on every minutes, it currently enumerates every minutes from 0 to 59. It would be simpler to simply skip the enumeration in this case and just leave it at "Every minute past every hour".
var numberList = function(numbers, unit) {
if (numbers.length < 2) {
return moment()._locale.ordinal(numbers);
}
// skip enumeration
if (unit && unit === 'm' && numbers.length == 60)
return ' '; // "Every minute"
var last_val = numbers.pop();
return numbers.join(', ') + ' and ' + moment()._locale.ordinal(last_val);
};
The prettycron.js we get from NPM is not the same as found in this repository.
The one on npm does not works due to changes to cronParser, I think.
Can you bump version and push the latest version ?
Thanks
When used 7 for Sunday (cron entry accepts 0 as well as 7 for Sunday), the cron entry still prints Saturday.
console.log('cron entry for Saturday: ', prettyCron.toString('30 13 * * 6'));
This one correctly prints "cron entry for Saturday: 13:30 on Sat"
console.log('cron entry for Sunday: ', prettyCron.toString('30 13 * * 7'));
This one also prints "cron entry for Sunday: 13:30 on Sat" Where as it should have been "cron entry for Sunday: 13:30 on Sun"
* * * * * *
should yield "Every second".
30 * * * * *
should yield "Every 30th second past every minute".
Has anyone gotten this library to work? Is this dead? I imported the latest 0.11.0
version using the Git url but it's still not getting imported.
Say, I've got cron expression "28 4 * * * * 0" which compiles to "04:28 every day" (that's ok). But when I try to get next events, I get "Tomorrow at 8:28 AM". My timezone is UTC+4, so it's clear, that moment.js detects my locale, and since later.js sets dates in calendar in UTC (adding Z to the end) and all dates shift 4 hours ahead.
Maybe better choice will be operating on dates like all of them in UTC?
prettycron.js starts with initialization of moment, later (via require
) and cronParser. If you don't use require
, than cronParser will be undefined
It would be nice to have this package in the bower repository.
They don't work. Moment even has locale thingys that are already in use in prettyCron (see 44b7279).
Cron expression: 30 6 15 15 * *
Human readable: 06:30 on the 15th in Mar
Should be 06:30 on the 15th of every month (not just March)
As of da0eeac, there are tests, but only for the human-readable output (not the next-run output), and only in Node (not the browser).
If getNext
returned a date object instead of a string, I could format it to my liking and even use it for other purposes.
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.