2

Is there a equivalent on .net of the string parsing of Datejs ( http://www.datejs.com/ ) ?

I wanna do things like

// 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′);

Tks!

Alex Takitani
  • 491
  • 5
  • 14

2 Answers2

2

The closest thing in the framwork is DateTime.Parse and DateTime.TryParse. Unfortunately, these will only handle your last 2 cases, but the first 3 will not work.

There is no built-in way to do date manipulations using the standard DateTime parsing methods. However, this answer to a different question provides a utility class which will handle some of your other cases (or something similar), using regular expressions.

Community
  • 1
  • 1
Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
0

As Reed mentions, there is nothing like this built into the .Net framework.

Microsoft JScript is a .Net language that can be used for server-side processing; you might look into seeing if you can integrate Datejs that way.

Aric TenEyck
  • 8,002
  • 1
  • 34
  • 48