chronic icon indicating copy to clipboard operation
chronic copied to clipboard

Undefined method start for nil class

Open fearnowrath opened this issue 8 years ago • 5 comments

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?

fearnowrath avatar Sep 27 '16 07:09 fearnowrath

@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)

SagareGanesh avatar Sep 27 '16 07:09 SagareGanesh

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?

fearnowrath avatar Sep 28 '16 04:09 fearnowrath

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

davispuh avatar Sep 28 '16 10:09 davispuh

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?

arezk84 avatar Oct 28 '18 11:10 arezk84

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.

Shnugs avatar Apr 04 '19 19:04 Shnugs