cron4s
cron4s copied to clipboard
Why is Monday is 0 in joda DateTime
I think Monday is 1 in crontab, But you make Monday is 0 in cron4s.lib.joda.JodaInstance why did you need have a offset to minus 1 when field is DayOfWeek?? cron4s.lib.joda.JodaInstance.scala(line 58)
val offset = if (field == DayOfWeek) -1 else 0
This is actually something we got bitten by too, the ISO standard and some IETF RFCs all indicate that 0 is Sunday, what standard is this library using?
I think this behaviour is the same for java.time as well. I was a bit confused by this because on some issues it has been mentioned that the library follows Quartz Cron expressions and on others the Wikipedia entry for cron, but Quartz uses e.g. SUN
to mean Sunday rather than a numeric value, and the existing behaviour doesn't follow either of the options described on the Wikipedia page as I have found that Sunday is represented by 6 in this library:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday;
# │ │ │ │ │ 7 is also Sunday on some systems)
# │ │ │ │ │
# │ │ │ │ │
# * * * * * <command to execute>