views:

391

answers:

6

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?

+2  A: 

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

casperOne
+4  A: 

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

vitorsilva
+1  A: 

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

Brandon
+1  A: 

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.

Feel free to contact me if you are interested: [email protected]

Eric
A: 

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.

BCS
A: 

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...

Sparky