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

reset milliseconds on DateTime return values #51

Closed
larsjaas opened this issue Feb 19, 2017 · 0 comments
Closed

reset milliseconds on DateTime return values #51

larsjaas opened this issue Feb 19, 2017 · 0 comments

Comments

@larsjaas
Copy link

cron4s currently preserves the milliseconds of the from value to the next() function and keeps it in the return value.

Let's say a task takes 100ms to perform. I set up "* * * * * *" as the CronExpr. Each time after the task is performed, I ask CronExpr to find the next once-a-second time based on the current time. I would expect to perform the task 60 times a minute, only slipping if the task itself lasted longer than one second. But because of drift caused by the current implementation I guess it would only be performed 54 times.

To avoid this kind of drift in cron-expressions that have periods of something triggering every second, the milliseconds-part of the returned time must be set to 0 (or you would have to keep an "origin" time around to use as milliseconds reference, which seems like a lot of extra complexity for no gain).

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

1 participant