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.14k stars 261 forks source link

Wrong description for * */2 * * * #477

Closed arunvelsriram closed 2 years ago

arunvelsriram commented 3 years ago

For * */2 * * * the expected description should be something like "every minute of every second hour". But actual description that we are getting is "every 2 hours".

Sorry if this a know bug already. I searched the issues but can't find anything related.

jmrozanec commented 3 years ago

@arunvelsriram thank you for reporting this. May we ask you to send a PR with a test? Thanks! 😄

mccartney commented 2 years ago

When looking into it, I think the problem is with default handling of Always values. So for an expression like * */2 * * * the handling of more specific values (left of */2) and less specific values (right of */2) is the same. Namely empty String. While it should be different.

I am not fully sure, but I think it should be:

i.e. https://github.com/jmrozanec/cron-utils/blob/864f9f09af58bd48133a1492a09fb7fbc1c5858b/src/main/java/com/cronutils/descriptor/DescriptionStrategy.java#L99 is too optimistic. It should have a conditional logic depending on what position of the expression is it.