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

Undefined method start for nil class #338

Open fearnowrath opened 7 years ago

fearnowrath commented 7 years ago

When i try to use Chronic.parse on the following I get an error.

require 'chronic'
puts Chronic.parse '9 hours and 43 minutes ago'

Error: /chronic/handlers.rb:517:in get_anchor': undefined method start=' for nil:NilClass (NoMethodError)

What could be causing the error?

SagareGanesh commented 7 years ago

@fearnowrath I think we don't have option like xx hours and xx minutes ago . Instead of this you can use xx hours before or xx minutes before. In your case you can use 583 minutes before. (9 hours and 43 minutes = 583 minutes)

fearnowrath commented 7 years ago

Thanks but why does it throw an error rather than just returning nil? Is it possible to at least make that return nil? Also any plans on adding support for this kind of format in the future?

davispuh commented 7 years ago

yeah, that is also a bug, and it should be pretty easy to add support for this format once #278 is finished

arezk84 commented 5 years ago

I have the same error

NoMethodError: undefined method start=' for nil:NilClass

If I just try to parse the character t

Chronic.parse("t")

Is there any updates?

Shnugs commented 5 years ago

I'm looking into solving this problem at the moment. Before I dig too deep into the code, I just wanted to see if there was any interest in resolving it or if we're fine with the workaround provided by @SagareGanesh.