3

Just wondering if anyone knows of an open source .Net library that handles dates similarly to the date.js library which allows you to do things like the following.

// What date is next thursday?
Date.today().next().thursday();

// Add 3 days to Today
Date.today().add(3).days();

// Is today Friday?
Date.today().is().friday();

// Number fun
(3).days().ago();

// 6 months from now
var n = 6;
n.months().fromNow();

// Set to 8:30 AM on the 15th day of the month
Date.today().set({ day: 15, hour: 8, minute: 30 });

// Convert text into Date
Date.parse('today');
Date.parse('t + 5 d'); // today + 5 days
Date.parse('next thursday');
Date.parse('February 20th 1973');
Date.parse('Thu, 1 July 2004 22:30:00');

I realize that the DateTime object in .Net already supports some of this functionality. I am especially interested in the last section of code which parses strings in an intelligent manner.

jessegavin
  • 74,067
  • 28
  • 136
  • 164
  • 1
    Some similar questions looking for natural language date parsers for .Net: http://stackoverflow.com/questions/55434/how-to-parse-relative-time , http://stackoverflow.com/questions/23689/natural-language-date-time-parser-for-net , http://stackoverflow.com/questions/466917/natural-language-parser-for-dates-net – quentin-starin Jul 20 '10 at 19:31

1 Answers1

2

I think the closest that you're going to get to date.js in the .NET world is noda-time.

Justin Niessner
  • 242,243
  • 40
  • 408
  • 536