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

Incorrect description: "0 0 2/4 * * ?" -> "every hour"

Open AlexBes1 opened this issue 11 years ago • 4 comments

"0 0 2/4 * * ?" is parsed like "every hour".

AlexBes1 avatar Oct 05 '15 16:10 AlexBes1

@AlexBes1 Thank you for reporting this. Will fix this as soon as possible.

jmrozanec avatar Oct 05 '15 17:10 jmrozanec

Something strange happen when we define for example 0 0 12 13 1/2 ? * and the description should be Day 13 of every 2 month(s) and the description is 'at 12:00 at 13 day every February months'.

I take a look and I think that the problem is in the every describe function: The nominal value should not be calculated because is an every instance.

like every x months / days / years

/**

 * Provide a human readable description for Every instance
 * @param every - Every
 * @return human readable description - String
 */
protected String describe(Every every, boolean and) {
    String description;
    if (every.getPeriod().getValue() > 1) {
        description = String.format("%s %s ", bundle.getString("every"), nominalValue(every.getPeriod())) + " %p ";
    } else {
        description = bundle.getString("every")+" %s ";
    }
    if(every.getExpression() instanceof Between){
        Between between = (Between) every.getExpression();
        description += MessageFormat.format(
                bundle.getString("between_x_and_y"),
                nominalValue(between.getFrom()),
                nominalValue(between.getTo())
        )+" ";
    }
    return description;
}

RafaelAbreu05 avatar Aug 25 '16 14:08 RafaelAbreu05

@RafaelAbreu05 don't you mind checking this in a separate branch, and if works ok, send a pull request to fix the issue? Thanks!

jmrozanec avatar Aug 25 '16 16:08 jmrozanec

@AlexBes1 @RafaelAbreu05 Fixed! Many thanks to @bertold for the fix!

jmrozanec avatar Oct 01 '17 20:10 jmrozanec