If you are coming to this series of posts for the first time you might check out my introductory post for a little context.
Chronic is a port of Ruby?s Chronic providing some natural language parsing for dates.
This is a pretty cool little utility as it lets you take some input like “tomorrow? or ?two weeks ago? and turn that into a DateTime object.
Take a look at some tests I pulled from https://github.com/robertwilczynski/nChronic/blob/master/src/Chronic.Tests/CustomParsingTest.cs.
[Fact]
public void seven_days_from_now_at_midnight()
{
Parse(” seven days from now at midnight”)
.AssertEquals(Time.New(2006, 8, 24));
}[Fact]
public void _2_weeks_ago()
{
Parse(“2 weeks ago”)
.AssertEquals(Time.New(2006, 8, 02, 14));
}[Fact]
public void two_weeks_ago()
{
Parse(“two weeks ago”)
.AssertEquals(Time.New(2006, 8, 02, 14));
I tried playing with it a bit. There seem to be some cases sensitivity issues with the codebase now as ?tomorrow? works but ?Tomorrow? doesn?t. But I think that?s a great reason to be on GitHub. Fork, fix, and send a pull request. All better?
I checked the class BasicExpressionsTests that you mentioned case sensitive issues for Tomorrow and ran the tests. I didn’t see any issues running the following code. This doesn’t work for you???
[Fact]
public void Tomorrow_is_parsed_correctly()
{
Parse(“Tomorrow”).AssertStartsAt(DateTime.Now.Date.AddDays(1));
}
Hey Peter,
This may be my lack of understanding how to use the project, however when I write the following tests (in the link below) I see different results than what I would expect. (Not sure if this is because the NuGet project is out of date form the source, but it looks like Install-Package chronic brings in 0.1.0)
http://codepaste.net/6figyb
Any thoughts?