-
Notifications
You must be signed in to change notification settings - Fork 53
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
Sub second precision is ignored and .next
returns time in past for same second
#160
Comments
Montrose doesn't support sub-second recurrence. When a recurrence is initialized, the start time for the recurrence interval is zero'd out to the current second. The issue you are describing will only exist when a recurrence is initialized at less than a second after a time which overlaps with the recurrence rules, as you have illustrated.
Probably, though I'd consider it minor. A simple patch with tests to address the issue is welcome.
We do generally want to support
Your workaround may lead to subtle bugs as well, since |
According to this line in the specs ...
montrose/spec/montrose/frequency/secondly_spec.rb
Line 16 in 2487a31
Montrose.every(:second).events.next
de facto returns a time in past, because it will always return a time that has sub second time set to0
.For example if you have a daily trigger
Montrose.every(:day).at('18:00:00')
and you runevents.next
at15.01.2020 18:00:00.500
(half a second past 18:00:00), it returns15.01.2020 18:00:00.000
which is in past (at least if you care about sub second precision).Is this a bug? Shouldn't
events.next
never return a time in the past?Edit: A workaround I just implemented is to do
Montrose::Recurrence.new(recurrence).take(3).find { |time| time >= Time.current }
.The text was updated successfully, but these errors were encountered: