Menu

Home Log in to Edit

Eric Hewitt

NaturalDate Natural Language Date Parsing .NET Module

Usage

  1. Click on the Downloads link and download NaturalDate.zip.
  2. Extract all zip file contents.
  3. Copy the Assembly file, NaturalDate.dll to your project directory.
  4. Add it as a reference to your project.
  5. Add the PrecisionSoftware namespace to the using list in your C# or Visual Basic file.
  6. Code against the NaturalDate API. Documentation is found in API Documentation/index.html

Example usages of NaturalDate

  1. Attempt to parse a date string:
    NaturalDate date;
    if (! NaturalDate.TryParse("January 1, 2009, 10-11PM", out date))
    {
    Console.WriteLine(date.ErrorString);
    }

  2. Enumerate a recurring date:
    foreach (NaturalDate d in NaturalDate.Enumerate("Every Friday", "January 1, 2009"))
    {
    Console.WriteLine(d);
    }

  3. Find the next occurrence of a recurring date:
    Console.WriteLine(NaturalDate.Next("Every Friday at 7PM", "January 1, 2009"));

  4. Using Linq, this example walks the week ahead, starting with today, and finds all events that overlap each day. It assumes EventList is an list of objects containing a 'When' property which is a NaturalDate.

    foreach (var day in NaturalDate.Enumerate("everyday", "today").Take(7))
    {
    var daysEvents = from e in EventList where e.When.Overlaps(day)
    orderby e.When.Next(day) select e;
    ...
    }


Discussion

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB