cron-utils icon indicating copy to clipboard operation
cron-utils copied to clipboard

Incorrect description for 0 59 10 ? 1/2 MON#1 *

Open maheshneogi opened this issue 9 years ago • 7 comments

Actual result : at 10:59 every February months Monday 1 of every month

Expected Result : SOMETHING LIKE "The 1st Monday of every two months at 10:59"

maheshneogi avatar Oct 14 '16 09:10 maheshneogi

@maheshneogi thank you for reporting this - the description proposed looks much better :) Can we add a test case for this? I will be glad to accept the pull request. Thanks!

jmrozanec avatar Oct 14 '16 17:10 jmrozanec

It seems there is a problem with iterations syntax. I found same problem with: Expression: 0 15/4 12 * * ? Description: every 4 minutes at 12 hour Next start: Tue Nov 08 12:15:00 CET 2016

"Next Start" is calculated using org.apache.logging.log4j.core.util.CronExpression

The original code is:

try {
    CronDescriptor cd = CronDescriptor.instance(Locale.ENGLISH);
    CronParser parser = new CronParser (CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
    final String cronExpression = "0 15/4 12 * * ?";
    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();
}

fante76 avatar Nov 08 '16 09:11 fante76

@fante76 I agree. Currently I would need more time to come back with a better way to get descriptions. If you have ideas / proposals, I will be glad to discuss.

jmrozanec avatar Nov 09 '16 09:11 jmrozanec

As you, if I could catch some extra time I will get a look in to the code.

Il 09/nov/2016 10:57, "jmrozanec" [email protected] ha scritto:

@fante76 https://github.com/fante76 I agree. Currently I would need more time to come back with a better way to get descriptions. If you have ideas / proposals, I will be glad to discuss.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jmrozanec/cron-utils/issues/126#issuecomment-259375413, or mute the thread https://github.com/notifications/unsubscribe-auth/AMXOMAbhizgzErSRpVxosp2zErO07aZBks5q8ZkFgaJpZM4KWzce .

fante76 avatar Nov 09 '16 12:11 fante76

So you are looking for something that is working like: https://www.freeformatter.com/cron-expression-generator-quartz.html ?

Naxos84 avatar Nov 16 '17 11:11 Naxos84

@Naxos84 we are looking to get that quality level of descriptions, but with the flexibility that cron-utils can provide regarding parsing expressions. We created a specific milestone to tackle this improvement. Probably some major changes will be required. Any thoughts on this are appreciated!

jmrozanec avatar Nov 17 '17 12:11 jmrozanec

Ok. I am going to think about this as soon as I am more comfortable with the project.

Am 17.11.2017 13:43 schrieb "jmrozanec" [email protected]:

@Naxos84 https://github.com/naxos84 we are looking to get that quality level of descriptions, but with the flexibility that cron-utils can provide. We created a specific milestone https://github.com/jmrozanec/cron-utils/milestone/8 to tackle this improvement. Probably some major changes will be required. Any thoughts on this are appreciated!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jmrozanec/cron-utils/issues/126#issuecomment-345234219, or mute the thread https://github.com/notifications/unsubscribe-auth/AQ_OIRe5wD7cppwZmpAkr-LrOGoiXFTZks5s3X9ZgaJpZM4KWzce .

Naxos84 avatar Nov 17 '17 17:11 Naxos84