Free from, input box style controls are always fascinating. Its always a pleasure to type in the dates and the computer understand it automatically. I came across the a
Date processing library that parses such free form dates. I was working on the
TwitteyBot over the weekend and I needed a component where a user could enter time durations.
As a requirement, the user would enter durations that resemble any of the following text
- 1 day, 10 hours and 15 minutes
- 1 minute + 1 hour
- Duration is 1 minute
I tried writing a parser, similar to Date.js and here it how it looks like.
The source code for parsing this is simple and self explanatory.