On Fri, 06 Feb 2004 18:13:59 -0700, Simple Simon <re***@newsgroup.only>
wrote:
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
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.