Closed JonPugsley closed 8 months ago
Hey @JonPugsley - I just tried that same command into my console, and the results were what you mentioned expecting:
Montrose.every(:week, interval: 2).on(["sunday", "monday"]).between(("2021-05-02".to_time)..("2021-05-22".to_time)).events.to_a
Are you using the most recent version of the gem?
@thewatts I have the same behavior
Hi @thewatts I also get the same output as @mikalai-yankouski and @JonPugsley ...
the version is the montrose (0.13.0)
Montrose depends on ActiveSupport for Date/Time calculations. For this recurrence, you'll see different results depending on whether the ActiveSupport Date.beginning_of_week
setting is set to Sunday or Monday.
@JonPugsley I suspect Monday is set as the beginning of week in the application where you were testing this recurrence. You could test this on the console: Date.beginning_of_week
.
You can get the results you are expecting with
Date.beginning_of_week = :sunday
Or in Rails
# config/application.rb
config.beginning_of_week = :sunday
I've added documentation and tests in #164 to further illustrate. Hope that is helpful.
I've been tinkering with this library and like what I see, though I've either found a bug or don't quite understand the options.
Pattern:
Events:
The matching dates are the sunday of one week, then the monday of the next week, then the sunday of the week after that![image](https://user-images.githubusercontent.com/29548310/117866907-0e3da600-b26e-11eb-8e53-c4f068be69a1.png)
I would expect the dates to be [2021-05-02, 2021-05-03, 2021-05-16, 2021-05-17]![image](https://user-images.githubusercontent.com/29548310/117867173-64124e00-b26e-11eb-8433-085625237817.png)
It seems like the library is running a Monday-Sunday week with no option to change this (though Sunday seems to have a day number of 0, which implies a Sunday-Monday week)