6

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"
Jordan Sitkin
  • 2,303
  • 3
  • 26
  • 35
  • possible duplicate of [fuzzy timestamp parsing with Python](http://stackoverflow.com/questions/1258712/fuzzy-timestamp-parsing-with-python) – Eli Bendersky Aug 13 '10 at 04:12
  • You can try http://www.datejs.com, it parses well usual date inputs but won't handle your 3 examples. I'm curious... What would you expect as a Javascript date for ie:"3 to 4 weeks"? – Mic Aug 13 '10 at 08:40
  • possible duplicate of [Is there a natural language parser for dates/times in ColdFusion?](http://stackoverflow.com/questions/1003330/is-there-a-natural-language-parser-for-dates-times-in-coldfusion) – Ben Doom Aug 13 '10 at 12:54
  • @Mic I'm not sure what would be most useful, but off the top of my head it would be cool if the parser could interpret a "min/max" date range when given a starting date (most often "Now") and a string such as those above. These examples would be "lead time" values in my app - ie, a user responds with a time window in which they can deliver their product. – Jordan Sitkin Aug 13 '10 at 18:57
  • @Mic to clarify my above comment: I would expect the hypothetical script to return **two** Date objects given one of the strings above and a starting date. – Jordan Sitkin Aug 13 '10 at 19:05

2 Answers2

4

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.

Steve Weet
  • 28,126
  • 11
  • 70
  • 86
0

Look here: Is there a natural language parser for dates/times in ColdFusion?

Community
  • 1
  • 1
Ben Doom
  • 7,865
  • 1
  • 27
  • 30