voidburn / cron-expression-descriptor

A Java library that converts cron expressions into human readable descriptions
https://github.com/voidburn/cron-expression-descriptor
MIT License
27 stars 11 forks source link

CRON expression "0 0 10 10 * *" produces incorrect description #15

Closed Nik-ADA closed 3 months ago

Nik-ADA commented 3 months ago

I encountered an issue with the library when processing the following CRON expression:

0 0 10 10

The output text generated by the library is:

At 10:00, on day 10 of the month.

However, other CRON parsers indicate that specifying both a day-of-week and a day-of-month parameter simultaneously should not be supported, and they throw the following error:

Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.

Could you please check and fix this issue?

voidburn commented 3 months ago

I agree with the issue, but this is the behaviour of the original project (https://bradymholt.github.io/cron-expression-descriptor).

I suggest not to use this package as a cron expression validation tool (i've seen many similar issues myself). Instead validate the expression with the runtime you actually use (JavaEE Schedule Expression or Quartz, others), report that error to the user, which will be accurate based on your cron scheduler runtime. If the runtime validates the expression, then and only then, you can use this to get an extended description.

This package should not be intended as a substitute for cron expression validation, I found many edge cases that are not managed correctly (sometimes even impossible to do so, since different engines deal with those edge cases differently).

I am sorry but I can't fix this, though the solution should be quite simple for you, as suggested above.