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

Unexpected results from matcher #22

Closed
simplenotezy opened this issue Jan 11, 2022 · 2 comments
Closed

Unexpected results from matcher #22

simplenotezy opened this issue Jan 11, 2022 · 2 comments
Labels
wontfix This will not be worked on

Comments

@simplenotezy
Copy link

Given the following expression:

const futureMatches = cronjsMatcher.getFutureMatches('0 2 * * 0', {
  startAt: new Date().toISOString(),
});

The following output is produced:

[
  '2022-01-12T02:00:00.864Z',
  '2022-01-13T02:00:00.864Z',
  '2022-01-14T02:00:00.864Z',
  '2022-01-15T02:00:00.864Z',
  '2022-01-16T02:00:00.864Z'
]

Which I wouldn't expect. I would expect a list of each Sunday at 02:00 - but perhaps I missunderstand the API?

@simplenotezy
Copy link
Author

It seems that this produces the right output: 0 2 ? * 0, however, it just doesn't seem like valid cron syntax: https://crontab.guru/#0_2_?_*_0

@brsanthu
Copy link
Collaborator

brsanthu commented Mar 15, 2022

dow (day of week) and dom (day of month) are very confusing. This confusion comes from, how to interpret when both are specified. Standard seems that if both are specified, then any day that matches either of them (dow or dom) should be considered as a match and many believe the same.

I cannot speak for crontab.guru but specifying * in any field means all values but crontab.guru is treating * as ignore char.

With that details, I think the library is behaving as designed. We documented this in the Readme

Cron expressions indicates time units which all should match for a time to match that expression. Given time matches cron expression if and only if second + minute + day (day of week or day of month) + month + year time units matches.

brsanthu added a commit that referenced this issue Mar 15, 2022
* Ignore ms if specified as part of startAt (#22)

* v1.2.1
@brsanthu brsanthu added the wontfix This will not be worked on label Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants