Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is Monday is 0 in joda DateTime #95

Open
youngce opened this issue Jan 8, 2018 · 2 comments
Open

Why is Monday is 0 in joda DateTime #95

youngce opened this issue Jan 8, 2018 · 2 comments
Labels

Comments

@youngce
Copy link

youngce commented Jan 8, 2018

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
@mfrawley
Copy link

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?

@DavidGregory084
Copy link

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants