Skip to content

Sub second precision is ignored and .next returns time in past for same second #160

@doits

Description

@doits

According to this line in the specs ...

assert frequency.include? now
... it seems to be intended, but just now it triggered a bug for me:

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 to 0.

For example if you have a daily trigger Montrose.every(:day).at('18:00:00') and you run events.next at 15.01.2020 18:00:00.500 (half a second past 18:00:00), it returns 15.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 }.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions