mojombo / chronic

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

last failing on first of the month #300

Open veesahni opened 9 years ago

veesahni commented 9 years ago

This works:

Chronic.parse("last 11:00", :now => Time.parse("2015-04-02 14:01:19 UTC"))
=> 2015-04-01 11:00:00 +0000

This doesn't:

Chronic.parse("last 11:00", :now => Time.parse("2015-04-01 14:01:19 UTC"))
ArgumentError: argument out of range
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic.rb:146:in `initialize'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic.rb:146:in `new'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic.rb:146:in `construct'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic/repeaters/repeater_day_portion.rb:50:in `next'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic/handlers.rb:521:in `get_anchor'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic/handlers.rb:414:in `handle_r'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic/handler.rb:76:in `invoke'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic/parser.rb:247:in `block in tokens_to_span'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic/parser.rb:244:in `each'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic/parser.rb:244:in `tokens_to_span'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic/parser.rb:61:in `parse'
        from /home/x/.rvm/gems/ruby-2.1.2/gems/chronic-0.10.2/lib/chronic.rb:90:in `parse'

The difference between the two is the date.