jmrozanec / cron-utils

Cron utils for parsing, validations and human readable descriptions as well as date/time interoperability.
http://cron-utils.com
Apache License 2.0
1.15k stars 262 forks source link

Incorrect description for "* /30 * * * *" #462

Closed norbertroamsys closed 3 years ago

norbertroamsys commented 3 years ago

Actual result : "every 30 minutes"

Expected Result : SOMETHING LIKE "Every second, every 30 minutes, starting at minutes past the hour" Please see: https://bradymholt.github.io/cron-expression-descriptor/ as one "reference".

It looks like the "seconds" part is ignored because "0 /30 " or "1 /30 " will generate the same output.

Test case/Code:

try {
    CronDescriptor cd = CronDescriptor.instance(Locale.ENGLISH);
    CronParser parser = new CronParser (CronDefinitionBuilder.instanceDefinitionFor(CronType.SPRING));
    final String cronExpression = "* /30 * * * *";
    Cron c = parser.parse(cronExpression);
    System.out.println("Expression:\t"+cronExpression);
    System.out.println("Description:\t"+cd.describe(c));
    CronExpression ce = new CronExpression(cronExpression);
    System.out.println("Next start:\t"+ce.getNextValidTimeAfter(new Date()));
} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

We find this smart library very helpful and hope that the issue may be easy to fix.

Thanks for support and/or feedback!

jmrozanec commented 3 years ago

@norbertroamsys thank you for reporting this. May we ask you to submit the test code as a PR? Thanks!

norbertroamsys commented 3 years ago

Hi @jmrozanec - I hope that's how it is suiteable for you. The JUnit test which contains the issue is set to Ignore. So you may merge and build it without fixing ;-).

jmrozanec commented 3 years ago

@norbertroamsys thank you! And have a happy new year! 😄

jmrozanec commented 3 years ago

@IndeedSi thanks! 😄