DateTime.Now falls between two dynamic DateTimes problem

DateTime.Now falls between two dynamic DateTimes problem

Post by Simple Sim » Sun, 08 Feb 2004 10:13:59


Hi all,
I'm struggling with an elegant way to figure out if DateTime.Now falls
between any Firday @ 6pm and Sunday @ 9pm.

ne1?
~Gordon
 
 
 

DateTime.Now falls between two dynamic DateTimes problem

Post by Morten Wen » Sun, 08 Feb 2004 20:51:55

On Fri, 06 Feb 2004 18:13:59 -0700, Simple Simon < XXXX@XXXXX.COM >



Well this would do it.

DateTime d = DateTime.Now;

switch(d.DayOfWeek)
{
case DayOfWeek.Friday:
if(d.Hour >= 18)
return true;
break;
case DayOfWeek.Saturday:
return true;
break; // for good measure
case DayOfWeek.Sunday:
if(d.Hour <= 21)
return true;
break;
default:
break;
}

return false;

Note, code is untested as I have no way to check it right now.

--
The hotmail account will most likely not be read, so please respond only
to the news group.

 
 
 

DateTime.Now falls between two dynamic DateTimes problem

Post by Simple Sim » Mon, 09 Feb 2004 04:25:25

Many thanks Morten :)

On Sat, 07 Feb 2004 12:51:55 +0100, Morten Wennevik