note 48130 deleted from ref.calendar by aidan
| From: | aidan@php.net | Date: | Fri, 17 Dec 2004 04:18:11 +0000 |
| Subject: | note 48130 deleted from ref.calendar by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81888@lists.php.net to get a copy of this message | ||
Note Submitter: rkkhuete at hotmail dot com
----
This is a function to make a calendar since 1980 without limit. You must pass the month and the
year, and the function will return an array. With this array you can fill a table to make the
calendar. The table will have got seven columns (obviously) and six rows. The first array's
element must be placed in the upper cell of the first row. The second element must be placed in the
upper cell of the second row, etc...
Raúl
===#=
//**********************************************
function calendario($mes, $año){
if(((($mes%2)!=0)&&($mes<=7))||((($mes%2)==0)&&($mes>7))){
$NumDiasMes="31";
}else{
if($mes=="2"){
if(($año%4)=="0"){
$NumDiasMes="29";
}else{
$NumDiasMes="28";
}
}else{
$NumDiasMes="30";
}
}
$añocero=array(2,5,5,1,3,6,1,4,7,2,5,7);
$incremento=$año-1980;
for ($i=1980;$i<($año);$i++){
if(($i%4)==0){
$incremento++;
}
}
if(($año%4==0)&&($mes>2)) $incremento++;
while($incremento>7) $incremento=$incremento-7;
$DiaSemanaInicio=($añocero[abs($mes)-1]+$incremento);
while($DiaSemanaInicio>7) $DiaSemanaInicio=$DiaSemanaInicio-7;
if ($DiaSemanaInicio==0) $DiaSemanaInicio=7;
for($i=0;$i<$NumDiasMes;$i++){
$aux=$i+$DiaSemanaInicio-1;
$celda[$aux]=$i+1;
}
return $celda;
}