<p>Does anyone know of a .NET date/time parser similar to <a href="http://chronic.rubyforge.org/" rel="noreferrer">Chronic for Ruby</a> (handles stuff like "tomorrow" or "3pm next thursday")?</p>

<p>Note: I do write Ruby (which is how I know about Chronic) but this project must use .NET.</p>

[{'answer_id': 23833, 'author': 'Burton', 'author_id': 1493, 'author_profile': 'https://Stackoverflow.com/users/1493', 'pm_score': 2, 'selected': False, 'text': '<p>I\'m not aware of one, but it sounded like a cool problem, so here\'s my whack at it (VB.NET):</p>\n\n<pre><code>Private Function ConvertDateTimeToStringRelativeToNow(ByVal d As DateTime) As String\n    Dim diff As TimeSpan = DateTime.Now().Subtract(d)\n    If diff.Duration.TotalMinutes &lt; 1 Then Return "Now"\n\n    Dim str As String\n    If diff.Duration.TotalDays &gt; 365 Then\n        str = CInt(diff.Duration.TotalDays / 365).ToString() &amp; " years"\n    ElseIf diff.Duration.TotalDays &gt; 30 Then\n        str = CInt(diff.TotalDays / 30).ToString() &amp; " months"\n    ElseIf diff.Duration.TotalHours &gt; 24 Then\n        str = CInt(diff.Duration.TotalHours / 24) &amp; " days"\n    ElseIf diff.Duration.TotalMinutes &gt; 60 Then\n        str = CInt(diff.Duration.TotalMinutes / 60) &amp; " minutes"\n    Else\n        str = CInt(diff.Duration.TotalMinutes).ToString() &amp; " minutes"\n    End If\n    If str.StartsWith("1") Then str = str.SubString(0, str.Length - 1)\n    If diff.TotalDays &gt; 0 Then\n        str &amp;= " ago"\n    Else\n        str &amp;= " from now"\n    End If\n    Return str\nEnd Function\n</code></pre>\n\n<p>It\'s really not as sophisticated as ones that already exist, but it works alright I guess.  Could be a nice extension method.</p>\n'}, {'answer_id': 23842, 'author': 'Nick', 'author_id': 1490, 'author_profile': 'https://Stackoverflow.com/users/1490', 'pm_score': 1, 'selected': False, 'text': "<p>@ Burton: I think he meant the other way, at least from the example on the linked page:</p>\n\n<pre><code>  Chronic.parse('tomorrow')\n    #=&gt; Mon Aug 28 12:00:00 PDT 2006\n\n  Chronic.parse('monday', :context =&gt; :past)\n    #=&gt; Mon Aug 21 12:00:00 PDT 2006\n\n  Chronic.parse('this tuesday 5:00')\n    #=&gt; Tue Aug 29 17:00:00 PDT 2006\n</code></pre>\n\n<p>I thought I would take a stab at it too until I realized! (nice implementation though)</p>\n"}, {'answer_id': 24178, 'author': 'Blair Conrad', 'author_id': 1199, 'author_profile': 'https://Stackoverflow.com/users/1199', 'pm_score': 3, 'selected': False, 'text': '<p>I don\'t, but there\'s a Java port called <a href="https://jchronic.dev.java.net/" rel="nofollow noreferrer">jchronic</a>. If nothing else, it could provide a good jumping-off point for your own. Or perhaps you could use a semi-automatic Java to C# translator like <a href="http://www.remotesoft.com/octopus/try.html" rel="nofollow noreferrer">Octopus</a> to help translate it. (Or something better, if anyone knows of anything.)</p>\n\n<p>Okay, another possible avenue: could you use the chronic code using <a href="http://www.ironruby.net/" rel="nofollow noreferrer">IronRuby</a>?</p>\n'}, {'answer_id': 32530, 'author': 'palmsey', 'author_id': 521, 'author_profile': 'https://Stackoverflow.com/users/521', 'pm_score': 2, 'selected': False, 'text': '<p>@Blair Conrad - Good ideas! I tried to get Chronic running under IronRuby but had some problems with dependencies - I don\'t know that it\'s ready yet.</p>\n\n<p>I found a project on <a href="http://www.codeplex.com" rel="nofollow noreferrer">Codeplex</a> (<a href="http://www.codeplex.com/DateTimeEnglishParse" rel="nofollow noreferrer">DateTimeEnglishParser</a>) that is attempting to do the same thing. It doesn\'t handle years or time yet, but it\'s a good start. I\'ve worked on the project a little and contributed a patch to better handle written numbers.</p>\n\n<p>It\'s an interesting problem, and has definitely helped me understand regular expressions better, so I think I\'ll keep working on it.</p>\n'}, {'answer_id': 466980, 'author': 'Sanjay Sheth', 'author_id': 57680, 'author_profile': 'https://Stackoverflow.com/users/57680', 'pm_score': 2, 'selected': False, 'text': '<p>There was a <a href="https://stackoverflow.com/questions/55434/how-to-parse-relative-time">similar thread</a> earlier and it gave a link to a library on CodeProject that seems to do what you want: <a href="http://www.codeproject.com/KB/edit/dateparser.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/edit/dateparser.aspx</a> but unfortunately the library seems to be written in MFC so you would have to make a DLL out of it and then call it from your .NET program.</p>\n'}, {'answer_id': 631134, 'author': 'Eric', 'author_id': 71020, 'author_profile': 'https://Stackoverflow.com/users/71020', 'pm_score': 5, 'selected': True, 'text': '<p>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: <a href="http://precisionsoftwaredesign.com/blog.php" rel="noreferrer">http://precisionsoftwaredesign.com/blog.php</a>.</p>\n\n<p>Feel free to contact me if you are interested: contact@precisionsoftware.us</p>\n\n<p>This library is now a SourceForge project.  The page is at:</p>\n\n<p><a href="http://www.SourceForge.net/p/naturaldate" rel="noreferrer">http://www.SourceForge.net/p/naturaldate</a></p>\n\n<p>The assembly is in the downloads section, and the source is available with Mercurial. </p>\n'}, {'answer_id': 845309, 'author': 'Owen', 'author_id': 425, 'author_profile': 'https://Stackoverflow.com/users/425', 'pm_score': 2, 'selected': False, 'text': '<p>Palmsey, I have just recently had the same requirment so I went ahead and wrote a simple parser. Its not the nicest code but it will handle things like:</p>\n\n<p>"Today at 2pm"\n"Tuesday at 2pm - 15th july 2010 at 2am"\n"Previous Year at 2am - Tommorow at 14:30"\n"18th july 2010 at 2:45pm" </p>\n\n<p>Stuck it on codeplex as maybe someone else will find it useful. Check it out: <a href="http://timestamper.codeplex.com/" rel="nofollow noreferrer">http://timestamper.codeplex.com/</a></p>\n'}, {'answer_id': 8571613, 'author': 'VitalyB', 'author_id': 126574, 'author_profile': 'https://Stackoverflow.com/users/126574', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve checked several frameworks and Python\'s <a href="http://code.google.com/p/parsedatetime/" rel="nofollow">ParseDateTime</a> worked the best. It can be used from .NET using IronPython. </p>\n\n<p>If anyone\'s interested in a full sample project, comment on the answer and I\'ll try to create one.</p>\n\n<p><strong>EDIT</strong></p>\n\n<p>As requested, here is a simple project that you can use with the library:</p>\n\n<p><a href="http://www.assembla.com/code/relativedateparser/subversion/nodes" rel="nofollow">http://www.assembla.com/code/relativedateparser/subversion/nodes</a></p>\n\n<p>Try the following usage case, for example:</p>\n\n<ul>\n<li>August 25th, 2008</li>\n<li>25 Aug 2008</li>\n<li>Aug 25 5pm</li>\n<li>5pm August 25</li>\n<li>next saturday</li>\n<li>tomorrow</li>\n<li>next thursday at 4pm</li>\n<li>at 4pm</li>\n<li>eod</li>\n<li>tomorrow eod</li>\n<li>eod tuesday</li>\n<li>eoy</li>\n<li>eom</li>\n<li>in 5 minutes</li>\n<li>5 minutes from now</li>\n<li>5 hours before now</li>\n<li>2 hours before noon</li>\n<li>2 days from tomorrow </li>\n</ul>\n'}, {'answer_id': 30074712, 'author': 'Doron Yaacoby', 'author_id': 3389, 'author_profile': 'https://Stackoverflow.com/users/3389', 'pm_score': 3, 'selected': False, 'text': '<p>A .NET port of Chronic exists. See <a href="https://github.com/robertwilczynski/nChronic" rel="noreferrer">https://github.com/robertwilczynski/nChronic</a>. I created a fork of it with some improvements and bug fixes, here: <a href="https://github.com/dorony/nChronic" rel="noreferrer">https://github.com/dorony/nChronic</a> (sent pull requests, the author still hasn\'t responded).</p>\n'}]
['https://Stackoverflow.com/questions/23689', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/521/']