1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| var classDate = Class.create(Date, {
initialize : function(){
_vecteurJours = Array("Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi");
_vecteurMois = Array("Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout",
"Septembre","Octobre","Novembre","Decembre");
},
getDatePaques : function(Annee){
if (Annee == null ) Annee = this.getFullYear();;
var C = Math.floor(Annee / 100);
var C_4 = Math.floor(C / 4);
// le nombre d'or diminué de 1
var G = Math.floor(Annee % (C - 1));
var E = Math.floor((8 * C + 13) / 25)
var H = Math.floor((19 * G + C - C_4 - E + 15) % 30);
var K = Math.floor(H / 28);
var P = Math.floor(29 / (H + 1));
var Q = Math.floor((21 - G) / 11);
// I représente le nombre de jours entre la pleine lune pascale et le 21 mars
var I = (K * P * Q - 1) * K + H;
var B = Math.floor(Annee / 4) + Annee;
var J1 = B + I + 2 + C_4 - C;
// J2 calcule le jour de la lune pascale
var J2 = Math.floor(J1 % 7);
var R = 28 + I - J2;
if (R > 31 ) return (new Date(Annee, 3, R - 31));
else return (new Date(Annee, 2, R));
},
toStringFr : function(){
return _vecteurJours[this.getDay()] +" "+
this.getDate() +" "+
_vecteurMois [this.getMonth()] +" "+
this.getFullYear();
},
setDay : function(X){
var Day=0;
if (this.getDay() == 0) Day = 7; // si le jour actuel est le Dimanche
if ( X == 0 ) X = 7; // si le jour rechercher est le Dimanche
if (X != Day ) { // si le jour recherché est différent d'aujourd'hui
if (X < Day) this.setDate(this.getDate() - (Day - X) );
else if (X > this.Day) this.setDate(this.getDate() + (X - Day) );
}
}
}); |
Partager