// ==============================
// Gilbert JAVAUX - PGJ Astronomie
// http://pagesperso-orange.fr/pgj/
// gjavaux@wanadoo.fr
// ==============================
// Script adapté en partie de "moontool.c" de John Walker, Release 2.0.
// ==============================
function date(){
var today=new Date();
jour = today.getUTCDate();
mois = today.getUTCMonth()+1;
annee = today.getUTCFullYear();
heure = today.getUTCHours();
minute = today.getUTCMinutes();
seconde = today.getUTCSeconds();
heure1 = heure + (minute / 60) +(seconde / 3600)
ggg = 1
if( annee < 1582 ) ggg = 0;
if( annee < 1582 && mois < 10 ) ggg = 0;
if( annee <= 1582 && mois == 10 && jour < 5 ) ggg = 0;
jd = - 1 * Math.floor(7 * (Math.floor((mois + 9) / 12) + annee) / 4);
s = 1
if ((mois - 9) < 0) s = - 1;
a = Math.abs(mois - 9);
j1 = Math.floor(annee + s * Math.floor(a / 7));
j2 = - 1 * Math.floor(((Math.floor(j1 / 100) + 1) * 3 / 4));
jd1 = jd + Math.floor((275 * mois / 9) + jour + (ggg * j2));
jd2dat1 = jd1 + 1721027 + 2 * ggg + 367 * annee - 0.5 ;
jj = jd2dat1 + (heure1 / 24)
jj2 = jj
}
var d2r=Math.PI/180;
var r2d=180/Math.PI;
/* JYEAR -- Convert Julian date to year, month, day, which are
returned as an Array. */
function jyear(td) {
var z, f, a, alpha, b, c, d, e, mm;
td += 0.5;
z = Math.floor(td);
f = td - z;
if (z < 2299161.0) {
a = z;
} else {
alpha = Math.floor((z - 1867216.25) / 36524.25);
a = z + 1 + alpha - Math.floor(alpha / 4);
}
b = a + 1524;
c = Math.floor((b - 122.1) / 365.25);
d = Math.floor(365.25 * c);
e = Math.floor((b - d) / 30.6001);
mm = Math.floor((e < 14) ? (e - 1) : (e - 13));
return new Array(
Math.floor((mm > 2) ? (c - 4716) : (c - 4715)),
mm,
Math.floor(b - d - Math.floor(30.6001 * e) + f)
);
}
/* JHMS -- Convert Julian time to hour, minutes, and seconds,
returned as a three-element array. */
function jhms(j) {
var ij;
j += 0.5; /* Astronomical to civil */
ij = (j - Math.floor(j)) * 86400.0;
return new Array(
Math.floor(ij / 3600),
Math.floor((ij / 60) % 60),
Math.floor(ij % 60));
}
/* DTR -- Degrees to radians. */
function dtr(d)
{
return (d * Math.PI) / 180.0;
}
/* PAD -- Pad a string to a given length with a given fill character. */
function pad(str, howlong, padwith) {
var s = str.toString();
while (s.length < howlong) {
s = padwith + s;
}
return s;
}
/* EDATE -- Edit date and time to application specific format. */
var Months = new Array( "janvier à ", "février à ", "mars à ", "avril à ", "mai à ", "juin à ",
"juillet à ", "aout à ", "septembre à ", "octobre à ", "novembre à ", "décembre à "
);
function edate(j) {
var date, time;
j += (30.0 / (24 * 60 * 60)); // Round to nearest minute
date = jyear(j);
time = jhms(j);
return (zero(date[2], 2, " ")) + " " + Months[date[1] - 1] + " " +
(zero(time[0], 2, " ")) + "h" + (zero(time[1], 2, "0"));
}
function dsin(x) {return Math.sin(dtr(x));}
function dcos(x) {return Math.cos(dtr(x));}
function zero(ze) {if (ze<10) ze="0"+ze;return ze}
function norm(x){
x = x - Math.floor(x);
if( x < 0 )
x = x + 1;
return x;
}
function permute(){
if (yp[0] > yp[1]) {
yp[0] = pl[1]; yp[1] = pl[2]; yp[2] = pl[3]; yp[3] = pl[0];
yph[0] = ph[1]; yph[1] = ph[2]; yph[2] = ph[3]; yph[3] = ph[0];
}
if (yp[1] > yp[2]) {yp[0] = pl[2]; yp[1] = pl[3]; yp[2] = pl[0]; yp[3] = pl[1];
yph[0] = ph[2]; yph[1] = ph[3]; yph[2] = ph[0]; yph[3] = ph[1];
}
}
function phase_lune_approx(phase) {
SynMonth = 29.53058868
k = (annee + fnj - 1900) * 12.3685;
k += 0.5;
k = Math.floor(k);
k += phase;
t = (jj - 2415020) / 36525;
t = k / 1236.85;
t2 = t * t;
t3 = t2 * t;
pt = 2415020.75933 + SynMonth * k + 0.0001178 * t2 - 0.000000155 * t3 + 0.00033 * Math.sin((166.56 + 132.87 * t - 0.009173 * t2) * d2r);
return pt;
}
function phase_lune(phase) {
SynMonth = 29.53058868
k = (annee + fnj - 1900) * 12.3685;
k += 0.5;
k = Math.floor(k);
k += phase;
t = (jj - 2415020) / 36525;
t = k / 1236.85;
t2 = t * t;
t3 = t2 * t;
pt = 2415020.75933 + SynMonth * k + 0.0001178 * t2 - 0.000000155 * t3 + 0.00033 * Math.sin((166.56 + 132.87 * t - 0.009173 * t2) * d2r);
m = 359.2242 + 29.10535608 * k - 0.0000333 * t2 - 0.00000347 * t3;
mprime = 306.0253 + 385.81691806 * k + 0.0107306 * t2 + 0.00001236 * t3;
f = 21.2964 + 390.67050646 * k - 0.0016528 * t2 - 0.00000239 * t3;
if (phase == 0||phase == 0.5) {
pt += (0.1734 - 0.000393 * t) * Math.sin(m * d2r);
pt += 0.0021 * Math.sin(2 * m * d2r);
pt -= 0.4068 * Math.sin(mprime * d2r);
pt += 0.0161 * Math.sin(2 * mprime * d2r);
pt -= 0.0004 * Math.sin(3 * mprime * d2r);
pt += 0.0104 * Math.sin(2 * f * d2r);
pt -= 0.0051 * Math.sin((m + mprime) * d2r);
pt -= 0.0074 * Math.sin((m - mprime) * d2r);
pt += 0.0004 * Math.sin((2 * f + m) * d2r);
pt -= 0.0004 * Math.sin((2 * f - m) * d2r);
pt -= 0.0006 * Math.sin((2 * f + mprime) * d2r);
pt += 0.0010 * Math.sin((2 * f - mprime) * d2r);
pt += 0.0005 * Math.sin((m + 2 * mprime) * d2r);
}
if (phase == 0.25||phase == 0.75) {
pt += (0.1721 - 0.0004 * t) * Math.sin(m * d2r);
pt += 0.0021 * Math.sin(2 * m * d2r);
pt -= 0.6280 * Math.sin(mprime * d2r);
pt += 0.0089 * Math.sin(2 * mprime * d2r);
pt -= 0.0004 * Math.sin(3 * mprime * d2r);
pt += 0.0079 * Math.sin(2 * f * d2r);
pt -= 0.0119 * Math.sin((m + mprime) * d2r);
pt -= 0.0047 * Math.sin((m - mprime) * d2r);
pt += 0.0003 * Math.sin((2 * f + m) * d2r);
pt -= 0.0004 * Math.sin((2 * f - m) * d2r);
pt -= 0.0006 * Math.sin((2 * f + mprime) * d2r);
pt += 0.0021 * Math.sin((2 * f - mprime) * d2r);
pt += 0.0003 * Math.sin((m + 2 * mprime) * d2r);
pt += 0.0004 * Math.sin((m - 2 * mprime) * d2r);
pt -= 0.0003 * Math.sin((2 * m + mprime) * d2r);
}
if (phase == 0.25) {pt += 0.0028 - 0.0004 * Math.cos(m * d2r) + 0.0003 * Math.cos(mprime * d2r);}
if (phase == 0.75) {pt += - 0.0028 + 0.0004 * Math.cos(m * d2r) - 0.0003 * Math.cos(mprime * d2r);}
return pt;
}
function gen() {
date()
window.status = "Calcul en cours...";
nj = Math.floor(275 * mois / 9) - 2 * Math.floor((mois + 9) / 12) + jour - 30;
fnj = nj / 365;
pl = new Array(4)
ph = new Array(4)
yp= new Array(4)
yph= new Array(4)
ph[0] = "Nouvelle Lune :"
ph[1] = "Premier Quartier :"
ph[2] = "Pleine Lune :"
ph[3] = "Dernier Quartier :"
n = 0
for (i = 0; i < 5; i++){
interm = phase_lune_approx(n);
if (pt - jj > 14) {fnj -= 0.0397; pl[i] = phase_lune(n); fnj += 0.0397}
else {pl[i] = phase_lune(n);}
n = n + 0.25
}
var count=pl[0]
if (count>jj){count -= 29.530588853}
yp[0] = pl[0]; yp[1] = pl[1]; yp[2] = pl[2]; yp[3] = pl[3];
yph[0] = ph[0]; yph[1] = ph[1]; yph[2] = ph[2]; yph[3] = ph[3];
permute()
// calculate moon's age in days
ip = norm((jj - count) / 29.530588853);
var ag = ((ip * 29.53058868)*100)/100;
age=Math.round(ag)-1
if( age < 0 ) age = 28;
// calculate moon's age in days
ip = norm((jj - count) / 29.530588853);
var ag = ((ip * 29.53058868)*100)/100;
if (ag<3){
agh=(Math.floor(ag*24));
agm=Math.floor((ag*24-Math.floor(ag*24))*60);
agd = agh + "h "+ zero(agm) + "m";}
else {
agj=(Math.floor(ag))
agh=Math.floor((ag*24)-(agj*24));
agm=Math.floor((((ag*24)-(agj*24))-agh)*60);
agd = agj + "jours " + zero(agh) + "heures "+ zero(agm) + "minutes ";}
document.write('
| ')
document.write(" " + yph[0] + " " + edate(yp[0]) +" ") document.write(" " + yph[1] + " " + edate(yp[1]) +" ") document.write(" " + yph[2] + " " + edate(yp[2]) +" ") document.write(" " + yph[3] + " " + edate(yp[3]) +" ") document.write(' Age de la lune : ' + agd + ' | ') document.write(' |