Git Product home page Git Product logo

prettycron's People

Contributors

anderssonjohan avatar andrebuchanan avatar audace avatar azza-bazoo avatar danielmschmidt avatar fdaugan avatar svenluijten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

prettycron's Issues

Cannot read property 'ordinal' of undefined

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 !!!

suport for every other/third minute, etc

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 * * *

v0.11.0 of prettycron

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!

getNextDate is incorrect when date and day are both specified

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"

Use 12 hour format on all cases

For me it's kind of inconsistent to have toStringreturning a 24h format and getNextreturning 12h format. I think it would be better to stick with only the more universal AM/PM format.

Showing incorrect time (using wrong timezone?)

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

Wrong description for expression with increments

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.

create-react-app & webpack error with later.js

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)

Incorrect English expression for `x * * * *`

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.

Wrong time and day of the week

The cron 30 10 * * 0 which means run at 10:30 every sunday is actually returned as "00:00 on Mon" by getPrettyCron().

my code:

var cron = "30 10 * * 0";
var schedule = later.parse.cron(cron, false);
console.log(getPrettyCron(schedule['schedules'][0]));

Every minute past every hour

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);
  };

Package not up to date on npm

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

Wrong day of the week displayed

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"

Support seconds

* * * * * * should yield "Every second".
30 * * * * * should yield "Every 30th second past every minute".

prettycron is not defined

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.

Calendar of next events and timezones

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?

Undefined cronParser if not using AMD

prettycron.js starts with initialization of moment, later (via require) and cronParser. If you don't use require, than cronParser will be undefined

Publish to bower

It would be nice to have this package in the bower repository.

Moar testing

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.