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

'sunday next week' returns nil during certain dates #344

Open havulinna opened 7 years ago

havulinna commented 7 years ago

Chronic.parse('sunday next week') appears to return nil when called during the current week. We have not noticed any issues while using it about a year now, but currently Chronic is not able to return sunday for next week.

Chronic.parse('sunday next week', now: Time.parse('2016-10-24 12:00:00 +0200')) # nil

I've tested it by experimenting different times as the now parameter. Calling the method with now set in the past or in the future works as expected:

Chronic.parse('sunday next week', now: Time.parse('2016-10-21 12:00:00 +0200')) # 2016-10-30 11:30:00 +0200
Chronic.parse('sunday next week', now: Time.parse('2016-11-01 12:00:00 +0200')) # 2016-11-13 12:00:00 +0200

I suspect the issue is related to daylight saving time, as our time zone will switch back to standard time on Sunday October 30th.

davispuh commented 7 years ago

yup, it is known DST issue #282, #147, #177, #179, #222, #228 and it's actually fixed in my unfinished rewrite branch, but no idea when I'll finish it.

erunyon commented 7 years ago

@davispuh Any update on when the rewrite branch will be released? We're running into the DST issue as well.

davispuh commented 7 years ago

It's actually been almost finished for really long time (more than a year) I just haven't been working on it for ages. For more info see #316 Anyway I just fixed last tests so now they all pass but it doesn't mean everything is working since there might be cases not covered by tests but they can be fixed once they come up.

# Running:

......................................................................................................

Finished in 11.438857s, 8.9170 runs/s, 67.4893 assertions/s.

102 runs, 772 assertions, 0 failures, 0 errors, 0 skips
Coverage report generated for Unit Tests to coverage. 3306 / 3528 LOC (93.71%) covered.

You can try and test it already #347

Only thing that's left to do is finish timezone support and then could release beta version. When that will happen no idea, but it could be ~soonish.