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

Error while getting next run date #134

Open
the-prksh opened this issue Jan 1, 2025 · 3 comments
Open

Error while getting next run date #134

the-prksh opened this issue Jan 1, 2025 · 3 comments

Comments

@the-prksh
Copy link

the-prksh commented Jan 1, 2025

Hello,

An unusual error we encountered on 31.12.2024. Upon further investigation, we believe that it may be due to a potential bug in the library.

Here is the way to reproduce the error in IEX:

$ iex
iex(1)> Mix.install [{:crontab,~> 1.1}]
:ok

iex(2)> expression = Crontab.CronExpression.Parser.parse!(0 9 2 1 * 2025)
~e[0 9 2 1 * 2025]

iex(3)> Crontab.Scheduler.get_next_run_date(expression, ~N[2024-12-31 20:27:53.909514])
{:error, “No compliant date was found for your interval.”}

For other dates its works as expected -

iex(4)> Crontab.Scheduler.get_next_run_date(expression, ~N[2024-12-30 20:27:53.909514])
{:ok, ~N[2025-01-02 09:00:00]}

iex(5)> Crontab.Scheduler.get_next_run_date(expression, ~N[2024-12-29 20:27:53.909514])
{:ok, ~N[2025-01-02 09:00:00]}

Could anyone please provide an explanation of what is causing this error and whether it is expected behavior?

@NicolayD
Copy link

NicolayD commented Jan 3, 2025

I think this bug happens only on Dec 31 of a leap year (in this case 2024). I saw the year incrementation was updated relatively recently (3 months ago), but this happens both with 1.1.13 and 1.1.14, haven't looked yet into more details with the code from 1.1.14.

@maennchen
Copy link
Owner

Thanks for the report. This has already been resolved on main while implementing full DateTime support.

The next release however depends on #133, so you'll have to be a bit patient.

The current main should be reasonably stable however, you should be able to use it for the moment with {:crontab, github: "maennchen/crontab"} in your mix.exs.

@NicolayD
Copy link

NicolayD commented Jan 7, 2025

@maennchen just tested and that seems to work, thanks a lot for the response!

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

No branches or pull requests

3 participants