Use the Chronic gem to parse values when casting to date and time. #66

wants to merge 1 commit into


None yet
4 participants

ndbroadbent commented Feb 4, 2012

Following on from #65.

Chronic provides natural language parsing, as well as being able to parse traditional formats. Also provides full timezone support.


ndbroadbent commented Feb 4, 2012

Also may affect #50 and #34.

myabc commented Feb 16, 2012

This is a cool idea, but I can't help feel that this is out of scope – at least as a default. I think the default behaviour should be to accept only those date / time formats that the core Ruby classes can parse.


ndbroadbent commented Feb 17, 2012

I was also thinking about that, and I first thought about writing a ransack_chronic gem that just overrides those parsing methods.

But the change turned out to be really small. By default, it parses all those date / time formats that the core Ruby classes can parse, but also adds some awesome natural language parsing, which is incredibly useful for 'floating' dates.
(e.g. "1 week ago" will always be 7 days ago from the time the search is executed.)

Anyway, moving this into a separate gem would also make sense. Or how about if Ransack detects the presence of Chronic, and uses it if available? Developers could add Chronic to their Gemfile if they want the extra functionality.

+1 my users would love this. separate gem or not.


ndbroadbent commented Nov 15, 2012

Didn't look like this was going anywhere, so I've created a ransack_chronic gem. Please try it out and let me know if you have any problems! Cheers

@ndbroadbent: thanks for that gem--saved me some time and is VERY useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment