/*------------------------------*/
|
/*
|
Titre : Affiche les dates du mois - Calendrier mensuel
|
|
Date édition : 15 Fev 2019
|
Date mise a jour : 28 Aout 2019
|
|
Rapport de la maj:
|
- fonctionnement du code vérifié
|
*/
|
/*------------------------------*/
|
|
function cal($month , $year , $lang , $type){
|
// recuperation des arguments
|
$numargs = func_num_args();
|
if ($numargs == 2)
|
{
|
$type = "list";
|
$lang = "en";
|
}
|
if ($numargs == 3)
|
{
|
$type = "list";
|
$lang = func_get_arg(2);
|
}
|
if ($numargs >= 4)
|
{
|
$type = func_get_arg(3);
|
$lang = func_get_arg(2);
|
}
|
setlocale(LC_TIME, $lang);
|
if (checkdate($month, 1, $year) != TRUE)
|
return;
|
$nbdays = date("t", mktime(0, 0, 0, $month, 1, $year));
|
if (strcmp($type, "array") == 0)
|
{
|
// recuperation du jour de la semaine ( 0 = dimanche, ... )
|
$one = date("w", mktime(0, 0, 0, $month, 1, $year));
|
// on remplit la 1e ligne avec le nom des jours
|
for ($i = 1; $i <= 7; $i++)
|
$c[0][$i-1] = strftime("%a", mktime(0, 0, 0, 10, $i, 2000));
|
// puis on remplit le calendrier
|
for ($i = 1; $i <= $nbdays; $i++)
|
$c[(($one+$i-1)/7)+1][($one+$i-1)%7] = $i;
|
return $c;
|
}
|
if (strcmp($type, "list") == 0)
|
{
|
// on remplit la liste avec les jours de la semaine
|
for ($i = 1; $i <= $nbdays; $i++)
|
$l[$i] = strftime("%A", mktime(0, 0, 0, $month, $i, $year));
|
return $l;
|
|
}
|
}
|
| ?> |