chronic icon indicating copy to clipboard operation
chronic copied to clipboard

"First Friday of next June" throws Runtime error in Chronic 0.10.2

Open freerobby opened this issue 10 years ago • 3 comments

irb(main):001:0> Chronic.parse "First Friday of next June"
RuntimeError: Current month should be set by now
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic/repeaters/repeater_month_name.rb:48:in `next'
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic/handlers.rb:529:in `get_anchor'
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic/handlers.rb:489:in `handle_o_r_g_r'
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic/handler.rb:76:in `invoke'
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic/parser.rb:260:in `block in tokens_to_span'
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic/parser.rb:258:in `each'
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic/parser.rb:258:in `tokens_to_span'
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic/parser.rb:61:in `parse'
    from /Users/robby/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/chronic-0.10.2/lib/chronic.rb:90:in `parse'
    from (irb):1

freerobby avatar Jun 28 '15 17:06 freerobby

Chronic doesn't really support such complex queries and mostly it's luck based whether it will get it correct :D anyway this works fine in my rewrite branch, but it's nowhere near ready for usage.

davispuh avatar Jun 29 '15 16:06 davispuh

@davispuh Thanks. Yes, I didn't intend this as a feature request (not that I'd be opposed), just as a bug because it should return nil rather than throw an exception. Seems like that piece is taken care of on your dev branch. Feel free to close if you decide this isn't a feature worth building. Thanks!

freerobby avatar Jun 29 '15 17:06 freerobby

with "works fine in my rewrite branch" I mean, it works there as it should producing correct output - feature already implemented there :)

davispuh avatar Jun 29 '15 18:06 davispuh