mojombo / chronic

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

incorrect parsing when introduce time #394

Closed MrMoins closed 3 years ago

MrMoins commented 5 years ago

I've found a strange behavior when I try to add a time in parser.

refdate = (Time.zone.now).beginning_of_week
  => Mon, 26 Aug 2019 00:00:00 CEST +02:00

Chronic.parse('this week thuesday', now: refdate)
  => 2019-08-29 00:30:00 +0000

Chronic.parse('this week thuesday at 9am', now: refdate)
  => 2019-08-25 09:00:00 +0000
davispuh commented 5 years ago

Add :guess => :begin option (or false) otherwise it picks middle of it found span...

MrMoins commented 5 years ago

the problem here is the date returned in the third result. it should be 2019-08-29 09:00:00 +0000 not 25

sathia27 commented 5 years ago
2.5.0 :041 > refdate
 => 2019-09-29 18:55:28 +0530

2.5.0 :027 > Chronic.parse('last week thuesday', now: refdate)
 => 2019-09-25 12:00:00 +0530

2.5.0 :040 > Chronic.parse('last week thuesday at 9am', now: refdate)
 => 2019-09-22 09:00:00 +0530

Is it because thursday spelling was wrong? It's working fine if I use right spelling.


2.5.0 :042 > Chronic.parse('last week thursday at 9am', now: refdate)
 => 2019-09-26 09:00:00 +0530```