Closed zoras closed 8 months ago
I figured out that this issue can be resolved by passing context: :none
irb(main):003:0> date = Date.new(2020,12,1)
=> Tue, 01 Dec 2020
irb(main):004:0> date.strftime('%A')
=> "Tuesday"
irb(main):005:0> Chronic.parse('1st tuesday this month', now: date)
=> 2020-12-08 12:00:00 +0100
irb(main):006:0> Chronic.parse('1st tuesday this month', context: :none, now: date)
=> 2020-12-01 12:00:00 +0100
Problem: When 1st date of the month falls on the same day where we query
nth day this month
, then 1st date day is ignored.Chronic Gem version:
0.10.2
Demo:
For December 2020, there are 5 Tuesdays as seen in calendar below:
Here chronic doesn't know 1st date is the 1st Tuesday. Chronic assumes there are only 4 Tuesdays on the month instead of 5.
Another example for November 2020, where 1st date of the month falls on a Sunday.
Here, chronic returns 3rd date as 1st Tuesday but misses the fact that 1st Sunday is 1st date of the month. Please also note that this month has 5 Sundays as well and not 4.