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

Describe day of week is incorrect

Open ElazarNeeman opened this issue 10 years ago • 8 comments

CronDescriptor descriptor = CronDescriptor.instance(locale); CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(QUARTZ); CronParser parser = new CronParser(cronDefinition); Cron quartzCron = parser.parse("0 0 8 ? * SUN *"); descriptor.describe(quartzCron); //returns "at 08:00 at Monday day" instead of "at 08:00 at Sunday"

Same for all days of week lag of 1.

ElazarNeeman avatar Aug 23 '16 13:08 ElazarNeeman

This still happen :(

RafaelAbreu05 avatar Aug 23 '16 15:08 RafaelAbreu05

@ElazarNeeman thank you for reporting the issue. @ElazarNeeman @RafaelAbreu05 You are welcome to contribute a test for it. A fix is always welcome as well :)

jmrozanec avatar Aug 23 '16 20:08 jmrozanec

Seems you have FieldDayOfWeekDefinitionBuilder.mondayDoWValue = 1 and use CronDefinitionBuilder.quartz ... .withMondayDoWValue(2)...

Probably by just using 1 there to match it should fix the issue I would think

MrForms avatar Sep 01 '16 15:09 MrForms

@MrForms thank you for the insight. Won't you mind sending a PR with the fix? I would highly appreciate that! Thanks!

jmrozanec avatar Sep 01 '16 16:09 jmrozanec

@MrForms and @jmrozanec this doesn't work.

First I use the Cron Type Quartz that already have this option and didn't work:

CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ); (..) .withDayOfWeek().withValidRange(1, 7).withMondayDoWValue(2).supportsHash().supportsL().supportsW().supportsQuestionMark().and() (..)

After I tried manually defining myself the cron trype and the problem persists.

After some debugging I notice the problem is because you use the DateTime (Joda time API) and this API only supports:

public static final int MONDAY = 1; public static final int TUESDAY = 2; public static final int WEDNESDAY = 3; public static final int THURSDAY = 4; public static final int FRIDAY = 5; public static final int SATURDAY = 6; public static final int SUNDAY = 7; (http://joda-time.sourceforge.net/userguide.html)

return new DateTime().withDayOfWeek(integer).dayOfWeek().getAsText(bundle.getLocale());

RafaelAbreu05 avatar Sep 02 '16 13:09 RafaelAbreu05

@ElazarNeeman Thanks for the insight. If you have some time, I would appreciate a PR for the test and fix as well. Thanks!

jmrozanec avatar Sep 02 '16 15:09 jmrozanec

@ElazarNeeman @RafaelAbreu05 @MrForms Many thanks to @markash for solving this issue!

jmrozanec avatar Jan 02 '17 12:01 jmrozanec

@ElazarNeeman @RafaelAbreu05 @MrForms @markash version 6.0.0 was released with this!

jmrozanec avatar May 22 '17 03:05 jmrozanec