tags:

views:

338

answers:

3

I was wondering if anyone could suggest a utility library that has useful functions for handling dates in ASP.NET easily taking away some of the leg work you normally have to do when handling dates?

Subsonic Sugar has some really nice functions:

http://subsonichelp.com/html/1413bafa-b5aa-99aa-0478-10875abe82ec.htm http://subsonicproject.googlecode.com/svn/trunk/SubSonic/Sugar/

Is there anything better out there?

I was wanting to work out the start(mon) and end(sun) dates of the last 5 weeks.

I was thinking something like this:

DateTime Now = DateTime.Now;

while(Now.DayOfWeek != DayOfWeek.Monday)
{
    Now.AddDays(-1);
}

for(int i=0; i<5;i++)
{
    AddToDatesList(Now, Now.AddDays(7));
    Now.AddDays(-7);
}

but this seems crappy? Plus this is not exactly what i want because i need the time of that start date to be 00:00:00 and the time of the end date to be 23:59:59

+3  A: 

Is there a specific problem you are trying to handle with dates? If the existing date API in .NET can handle your problem cleanly, I see no reason to consider a 3rd party library to do it. When I was in .NET, we had to deal with dates quite a bit, and the standard libraries provided a fair amount of functionality to us.

Mike Stone
A: 

What exactly do you want to do that System.DateTime and System.Timespan can't handle?

Joel Coehoorn
Probably calculate the age of the universe or time left till doomsday... :P
Andrei Rinea
A: 

CSLA has a useful helper class called SmartDate that addresses quite a lot of the problems when using dates in real applications. As far as I can recall it's coupled to the rest of the framework.

Rik Garner