Skip to content

Hourly on Specific Minute #181

@eric1234

Description

@eric1234

If I wanted a recurrence that is every day at 8 I can do this:

> puts Montrose.daily(hour: 8).take(10)
2025-03-28 08:53:34 -0400
2025-03-29 08:53:34 -0400
2025-03-30 08:53:34 -0400
2025-03-31 08:53:34 -0400
2025-04-01 08:53:34 -0400
2025-04-02 08:53:34 -0400
2025-04-03 08:53:34 -0400
2025-04-04 08:53:34 -0400
2025-04-05 08:53:34 -0400
2025-04-06 08:53:34 -0400

I can even make it exactly on the hour by using the minute: 0 (although not exactly on the 0 sec):

> puts Montrose.daily(hour: 8, minute: 0).take(10)
2025-03-28 08:00:12 -0400
2025-03-29 08:00:12 -0400
2025-03-30 08:00:12 -0400
2025-03-31 08:00:12 -0400
2025-04-01 08:00:12 -0400
2025-04-02 08:00:12 -0400
2025-04-03 08:00:12 -0400
2025-04-04 08:00:12 -0400
2025-04-05 08:00:12 -0400
2025-04-06 08:00:12 -0400

But if I want to go one notch down in period and instead of daily at a certain hour do hourly at a certain minute:

puts Montrose.hourly(minute: 8).take(10)

This is accepted but it is caught in an infinate loop. Now I can work around this by indicating a start option that starts me on the 8th minute:

> puts Montrose.hourly(minute: 8, starts: Time.current.change(min: 8) + 1.hour).take(10)
2025-03-27 17:08:00 -0400
2025-03-27 18:08:00 -0400
2025-03-27 19:08:00 -0400
2025-03-27 20:08:00 -0400
2025-03-27 21:08:00 -0400
2025-03-27 22:08:00 -0400
2025-03-27 23:08:00 -0400
2025-03-28 00:08:00 -0400
2025-03-28 01:08:00 -0400
2025-03-28 02:08:00 -0400

But it seems I shouldn't have to specify the start time since I didn't have to do that for a certain hour every day.

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