mojombo / chronic

Chronic is a pure Ruby natural language date parser.
http://injekt.github.com/chronic
MIT License
3.24k stars 458 forks source link

1st Sunday in January gives Jan 1st but 1st Sunday this month gives Jan 8th #350

Open cruznunez opened 7 years ago

cruznunez commented 7 years ago

Got some unexpected results when I tried to use the first day of the month with 1st, 2nd, 3rd, 4th, or 5th.

today = Date.new(2017, 1, 1)

Chronic.parse "1st Sunday this month", now: today
=> Sun, 08 Jan 2017 12:00:00 EST -05:00

Chronic.parse "2nd Sunday of this month", now: today
=> Sun, 15 Jan 2017 12:00:00 EST -05:00

Chronic.parse "1st Sunday in January", now: today
=> Sun, 01 Jan 2017 12:00:00 EST -05:00

Chronic.parse "2nd Sunday in January", now: today
=> Sun, 08 Jan 2017 12:00:00 EST -05:00

Chronic.parse("1st Sunday in January", now: today) == Chronic.parse("1st Sunday this month", now: today)
=> false

Anyone else getting this?

davispuh commented 7 years ago

Looks like same issue as #295

It's fixed in my rewrite branch which isn't ready yet.