Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intelligent date range parsing of human input?

Has anyone come across a script / cl app written in any language that handles the parsing of human-entered dates well? I'd love to be able to parse, for example:

  • "3 to 4 weeks"
  • "2 - 3 days"
  • "3 weeks to 2 months"
like image 492
Jordan Sitkin Avatar asked Aug 13 '10 04:08

Jordan Sitkin


1 Answers

The Chronic gem for ruby will allow you to express dates in a natural form.

Some examples of supported forms (from the documentation)

  thursday
  november
  summer
  friday 13:00
  mon 2:35
  4pm
  yesterday at 4:00
  last friday at 20:00
  last week tuesday
  tomorrow at 6:45pm
  afternoon yesterday
  thursday last week
  3 years ago
  5 months before now
  7 hours ago
  7 days from now
  1 week hence
  in 3 hours
  1 year ago tomorrow

I have not used it so can not comment on its performance.

like image 147
Steve Weet Avatar answered Oct 04 '22 03:10

Steve Weet