cron-utils
cron-utils copied to clipboard
Incorrect descriptor result
Hello, @jmrozanec. I use next cron expression 0 0 0 ? * 6 * and use class CronDescriptor.instanse(Msg.getCurrent()).describe() I want to get at 00:00 at and Saturday day. I get at 00:00 at and Friday days I debug code and find that in DescriptionStrategyFactory, diff is always =-1, but if it is 0 result will be correct.
final Function<Integer, String> nominal = integer -> {
int diff = definition instanceof DayOfWeekFieldDefinition ? DayOfWeek.MONDAY.getValue() - ((DayOfWeekFieldDefinition) definition).getMondayDoWValue().getMondayDoWValue() : 0;
return DayOfWeek.of(integer + diff < 1 ? 7 : integer + diff).getDisplayName(TextStyle.FULL, bundle.getLocale());
};
@kostya05983 thank you for reporting this. We would appreciate if you can send a PR with the corresponding test. We will try to fix it as soon as possible and release a new version with it. Help is always welcome! 😄
@jmrozanec I understand that it is happened because the week starts on sunday, how do you think, is it possible to provide functionality to start week on monday?
@kostya05983 please notice that we support Cron specifications to have a flexible start of week: you just need to specify which index corresponds to Monday at CronDefinitionBuilder: withMondayDoWValue(yourValueHere) Please let us know if further explanations are needed. Best!