Question

I want to be able to let users enter dates (including recurring dates) using natural language (eg "next friday", "every weekday"). Much like the examples at http://todoist.com/Help/timeInsert

I found this post, but it's a bit old and offered only one solution that I'm not entirely content with. I thought I'd resurrect this question and see: are there any other .NET libraries out there that do this kind of date parsing?

Was it helpful?

Solution

I know it's not an optimal solution but you can also try to port the dateJs library to .net

It handles things like today; tomorrow; July 2008; next friday; last April; 2004.08.07; 6/4/2005; 8:15 PM; 22:30:45; +5years

OTHER TIPS

I don't know of anything that you can use with the framework today that will allow you to do this, but if you are content with playing around with future bits, you can check out Oslo, and make your own textual DSL.

This article shows how to do exactly what you are trying to do:

http://www.infoq.com/articles/natural-language-date-dsl-oslo

DateTime.Parse() will take a string argument and attempt to generate its DateTime equal. I'm a bit rusty on it, but it should work for any date string which you can generate with DateTime.ToString().

You can also take a look at DateTime.ParseExact() which does the same thing as Parse(), but allows you to restrict the possible formats for the input string. The following link should help you out with both as well as any other date parsing functions in the framework.

http://msdn.microsoft.com/en-us/library/1k1skd40.aspx

We developed exactly what you are looking for on an internal project. We are thinking of making this public if there is sufficient need for it. Take a look at this blog for more details: http://precisionsoftwaredesign.com/blog.php.

I've built this library as part of a project at work. It's not totally polished but if you are interested, I can put some more work into it and/or arrange a license for your needs.

Very old program I wrote (using Clipper, an DBASE derivative), but the code is pretty readable.

http://www.jbooth-consulting.com/downloads/clipper/guessdate.zip

Might give you some ideas if you want to roll your own...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top