//Initialisation des variables globales var nsx = (document.layers)? true:false var iex = (document.all)? true:false var mois1 = new Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"); var jours1 = new Array ("Lu", "Ma", "Me", "Je", "Ve", "Sa", "Di"); var mc = ''; var mp = ''; var today = ''; var today2 = ''; var ligne; var s = 0; //Année bissextile function bissextile(annee){ if (annee % 4 == 0 && annee % 100 != 0 || annee % 400 == 0) return 29; else return 28;} //Extraction de l'année function anneeDate(amj) { return Math.floor(amj / 10000);} //Extraction du mois function moisDate(amj) { return Math.floor((amj - (anneeDate(amj) * 10000)) / 100);} //Extraction du jour function jourDate(amj) { return (amj - (anneeDate(amj) * 10000) - (moisDate(amj) * 100));} //La date est convertie en un nombre de jours theoriques (formule d'Euler) function date_en_jours(amj) { aa = anneeDate(amj); mm = moisDate(amj); jj = jourDate(amj); if (mm > 2) { var bis = Math.floor(aa/4) - Math.floor(aa/100) + Math.floor(aa/400); var za = Math.floor(aa * 365 + bis); var zm = (mm-1) * 31 - Math.floor(mm * 0.4 + 2.3); return (za + zm + jj); } else { var bis = Math.floor((aa-1)/4) - Math.floor((aa-1)/100) + Math.floor((aa-1)/400); var za = Math.floor(aa * 365 + bis); return (za + (mm-1) * 31 + jj);} } // nombre de jours separant amj2 et amj1 function difference_dates(amj1, amj2) { var nbj1 = date_en_jours(amj1); var nbj2 = date_en_jours(amj2); return(nbj2 - nbj1); } // 1=lun, ..., 7=dim function jour_semaine (amj) { var jr = date_en_jours(amj); return Math.floor((jr-2) % 7) + 1; } //Renvoie le numero de semaine d'une date function numero_semaine(amj) { var annee = anneeDate(amj); var debutannee = annee * 10000 + 101; var jrdeb = jour_semaine(debutannee); var jr = jour_semaine(amj); var nbj = difference_dates(debutannee,amj); var nbsem = Math.floor(nbj / 7) + 1; if (jr < jrdeb) nbsem++; if (jrdeb > 4) if (--nbsem == 0) nbsem = 53; return(nbsem); } //Convertit un objet Date JavaScript en date numerique aaaammjj function date_amj(x) { var today = new Date(); var aa = today.getYear(); mc = 'n'; mp = 'n'; if (aa < 2000) aa += 1900; var today2 = aa * 10000 + (today.getMonth()+1) * 100 + today.getDate(); if (x) {today=x; if (today2 == today) {mc='y';}; if (today2 < today) {mp='y';}} else {today=today2; mc='y';mp ='n';} return today;} //Ecrit le calendrier dans la page function calendrier(x) { ligne = ''; function setblue() { document.getElementById('texte').style.bgcolor='#ffffff'; } var tx = x; var dat = date_amj(tx); if (dat < 17520914) dat=17520914; var annee = anneeDate(dat); var ms = moisDate(dat); var jmax = 31; if (ms == 4 || ms == 6 || ms == 9 || ms == 11) jmax = 30; if (ms == 2) jmax = bissextile(annee); var zdate = annee * 10000 + ms * 100 + 1; // 1er janvier var jr = jour_semaine(zdate); var sem = numero_semaine(zdate); var tit=''; ligne +='
\n'; ligne +='\n'; ligne +='\n'; for (var i = 0; i < 7; i++) ligne+='\n'; ligne+='\n'; // on remplit jusqu'au 1er jour du mois for (var nbj = 1; nbj < jr; nbj++) ligne+=''; // puis on ecrit les jours du mois for (var nbj = 1; nbj <= jmax; nbj++) { if (nbj > 1 && (nbj+jr) % 7 == 2) { ligne+='\n'; s++; if (sem < 53) sem++; else sem=1; } var radic = 'x'+dat; radic = radic.substring(3,7); if (nbj <10) {var nbj2 = '0'+nbj;} else var nbj2 = nbj; if ((nbj < jourDate(dat))&&(mc == 'y')) {ligne+='\n';} else if ((nbj == jourDate(dat))&&(mc == 'y')&&(iseven[nbj] !='0')) {ligne+='\n';} else if ((nbj == jourDate(dat))&&(mc == 'y')) {ligne+='\n';} else if (iseven[nbj] !='0') {ligne+='\n';} else {ligne+='\n';} } // enfin on termine le tableau var x = (jmax+jr-1) % 7; if (x == 0) x = 7; for (var nbj = 0; nbj < 7-x ; nbj++) ligne+=''; ligne+='\n'; s++; if (s == 5) { ligne+=''; ligne+='\n'; } ligne+='
' + mois1[ms-1] + ' '+ annee + '
 '+sem+'
'+nbj+''+nbj+''+nbj+''+nbj+''+nbj+' '+sem+'
        
'; //Détermine m-1 et m+1 if (moisDate(dat) == '1') { yesterday = dat -8900; tommorow = dat + 100;} else if (moisDate(dat) == '12') { yesterday = dat - 100; tommorow = dat + 8900;} else { yesterday = dat - 100; tommorow = dat + 100;} if (mp == 'y') ligne+=''; else ligne+=''; ligne+=''; ligne+=''; ligne+='
'; return ligne; }