Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chronic.parse "1 year, 7 months ago" breaks #415

Open
bendangelo opened this issue Nov 14, 2023 · 3 comments
Open

Chronic.parse "1 year, 7 months ago" breaks #415

bendangelo opened this issue Nov 14, 2023 · 3 comments

Comments

@bendangelo
Copy link

Running that line gives this error:

[6] pry(main)> Chronic.parse "1 year, 7 months ago"
NoMethodError: undefined method `start=' for nil:NilClass
from /Users/ben/.rvm/gems/ruby-3.2.2/gems/chronic-0.10.2/lib/chronic/handlers.rb:517:in `get_anchor'
@sriram0601
Copy link

sriram0601 commented Nov 25, 2023

This discussion may helps you #338, or what is your expected result?

@bendangelo
Copy link
Author

Hi, thanks. I would expect something like this as the output:

Time.current - ChronicDuration.parse("1 year, 7 months ago")

Or at the very least it doesn't throw an error.

@Rockster160
Copy link

+1 Here. Running into the same issue.

::Chronic.parse("3 hours and 30 minutes ago")

The workaround is to break it apart: ::Chronic.parse("210 minutes ago"), but that is kind of the purpose of the gem, isn't it? That's not easy to do if you are pulling user-provided text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants