Script to figure out if it"s a weekend

Script to figure out if it"s a weekend

am 07.01.2008 23:17:34 von ysoussov

Hey does anyone know of an easy script to use to figure out whether
the current date is a weekend or not, i currently have a script that
returns the current date and time. Also it would be great if it could
take into account holidays.

Re: Script to figure out if it"s a weekend

am 07.01.2008 23:40:36 von Paul Lautman

ysoussov@gmail.com wrote:
> Hey does anyone know of an easy script to use to figure out whether
> the current date is a weekend or not, i currently have a script that
> returns the current date and time. Also it would be great if it could
> take into account holidays.

if (substr(date('D'),0,1) == 'S')

Re: Script to figure out if it"s a weekend

am 08.01.2008 00:35:54 von Chuck Anderson

ysoussov@gmail.com wrote:
> Hey does anyone know of an easy script to use to figure out whether
> the current date is a weekend or not, i currently have a script that
> returns the current date and time. Also it would be great if it could
> take into account holidays.
>

|gregoriantojd($month, $day, $year) % 7 = $day_of_the_week // Monday = 0|

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Nothing he's got he really needs
Twenty first century schizoid man.
***********************************

Re: Script to figure out if it"s a weekend

am 08.01.2008 00:39:14 von Steve

"Paul Lautman" wrote in message
news:5ufo34F1hgmsqU1@mid.individual.net...
> ysoussov@gmail.com wrote:
>> Hey does anyone know of an easy script to use to figure out whether
>> the current date is a weekend or not, i currently have a script that
>> returns the current date and time. Also it would be great if it could
>> take into account holidays.
>
> if (substr(date('D'),0,1) == 'S')

L.U.D.I.C.R.O.U.S !!!

$dateInfo = getdate(date());
$isWeekend = in_array($dateInfo['wday], array(0, 6));

using substr is rediculous. 'domingo' is sunday and is ONE reason your
suggestion blows.

Re: Script to figure out if it"s a weekend

am 08.01.2008 00:50:52 von Steve

"Chuck Anderson" wrote in message
news:XPydnf0HlbrEKh_anZ2dnUVZ_ruqnZ2d@comcast.com...
> ysoussov@gmail.com wrote:
>> Hey does anyone know of an easy script to use to figure out whether
>> the current date is a weekend or not, i currently have a script that
>> returns the current date and time. Also it would be great if it could
>> take into account holidays.
>>
>
> |gregoriantojd($month, $day, $year) % 7 = $day_of_the_week // Monday = 0|

forgot about modulus!

$dateInfo = getdate(date());
$isWeekend = $dateInfo['wday'] % 6 == 0;

that is faster than in_array. good catch.

Re: Script to figure out if it"s a weekend

am 08.01.2008 00:58:48 von Csaba

"Steve" wrote in message
news:wKygj.591$bC4.225@newsfe05.lga...
>
> "Paul Lautman" wrote in message
> news:5ufo34F1hgmsqU1@mid.individual.net...
>> ysoussov@gmail.com wrote:
>>> Hey does anyone know of an easy script to use to figure out
>>> whether
>>> the current date is a weekend or not, i currently have a script
>>> that
>>> returns the current date and time. Also it would be great if it
>>> could
>>> take into account holidays.
>>
>> if (substr(date('D'),0,1) == 'S')
>
> L.U.D.I.C.R.O.U.S !!!
>
> $dateInfo = getdate(date());
> $isWeekend = in_array($dateInfo['wday], array(0, 6));
>
> using substr is rediculous. 'domingo' is sunday and is ONE reason
> your suggestion blows.


if( date('N') == 6 || date('N') == 7)

Wouldnt that do it?

R.

Re: Script to figure out if it"s a weekend

am 08.01.2008 01:06:47 von Steve

"Richard" wrote in message
news:4782bcb2$0$42812$dbd43001@news.euronet.nl...
>
> "Steve" wrote in message
> news:wKygj.591$bC4.225@newsfe05.lga...
>>
>> "Paul Lautman" wrote in message
>> news:5ufo34F1hgmsqU1@mid.individual.net...
>>> ysoussov@gmail.com wrote:
>>>> Hey does anyone know of an easy script to use to figure out whether
>>>> the current date is a weekend or not, i currently have a script that
>>>> returns the current date and time. Also it would be great if it could
>>>> take into account holidays.
>>>
>>> if (substr(date('D'),0,1) == 'S')
>>
>> L.U.D.I.C.R.O.U.S !!!
>>
>> $dateInfo = getdate(date());
>> $isWeekend = in_array($dateInfo['wday], array(0, 6));
>>
>> using substr is rediculous. 'domingo' is sunday and is ONE reason your
>> suggestion blows.
>
>
> if( date('N') == 6 || date('N') == 7)
>
> Wouldnt that do it?

more than one way to skin a cat. :)