هذا الكود لاضهار التاريخ الهجري
<script language="javascript">
<!--
var D,M,Y;
var Jd,Gy,Gm,Gd;
var Hd,Hm,Hy;
var input="Gregorian";
Y2K = 2000;
DATE_F = 1900;
function getFullYear(myDate){
var fyr = myDate.getYear( );
if (fyr < Y2K) {fyr+=DATE_F;}
return fyr;
}
void function Gragerian2Hijri(){
Jd=Toj(Y,M,D);
Gy=AhBh(Y,input);
Gm=M;
Gd=D;
Toh (Jd);
}
function IslamicMonthNames (w){
this[1]= w ? "Moh":"محرم";
this[2]= w ? "Saf":"صفر";
this[3]= w ? "Ra1":"ربيع الأول";
this[4]= w ? "Ra2":"ربيع الثاني";
this[5]= w ? "Jo1":"جمادى الأول";
this[6]= w ? "Jo2":"جمادى الثاني";
this[7]= w ? "Raj":"رجب";
this[8]= w ? "Shb":"شعبان";
this[9]= w ? "Ram":"رمضان";
this[10]= w ? "Shw":"شوَال";
this[11]= w ? "ThQ":"ذو القعدى";
this[12]= w ? "ThH":"ذو الحجة";
}
function ChristianMonthNames (w){
this[1]= w ? "Jan":"January";
this[2]= w ? "Feb":"February";
this[3]= w ? "Mar":"March";
this[4]= w ? "Apr":"April";
this[5]= w ? "May":"May";
this[6]= w ? "Jun":"June";
this[7]= w ? "Jul":"July";
this[8]= w ? "Aug":"August";
this[9]= w ? "Sep":"September";
this[10]= w ? "Oct":"October";
this[11]= w ? "Nov":"November";
this[12]= w ? "Dec":"December";
}
function MonthName(Month,Calendar) {
var s=false;
var IslamicMonthName=new IslamicMonthNames (false);
var ChristianMonthName=new ChristianMonthNames (false);
if (Calendar=='Hijri') {s=true}
return s ? IslamicMonthName[Month]:ChristianMonthName[Month];
}
function Toh(I) {
var M=0;
var D=0;
var C=0;
var NMD=0;
var Days=0
var Months=0
JDIE= 1948437.5386277;
JDHI= 347997.4662037;
LC= 29.530594;
Days= I-JDIE;
Months= (I-JDIE)/LC;
C= Math.floor(Months);
NMD= NewMonth(C);
Dh=Math.floor(I-NewMonth(C,I))+1 ;
if (Dh < 1) {C -=1;Dh=Math.floor(I-NewMonth(C,I))+1};
Yh=Math.floor(C/12)+1;
Mh=C-(12*(Yh-1))+1;
Hd=Dh;Hm=Mh;
Hy=AhBh(Yh,'Hijri');
return Mh;
}
function NewMonth (Cycle,JDay) {
var NMM=0;
var NM=0;
var NMM2=0;
NMM=(Math.floor(Cycle)*LC)+JDIE;
NMM2=(Math.floor(Cycle+1)*LC)+JDIE;
/* the number after the '+' determines
the age of a moon required to start a month */
NM=Math.ceil(NMM+0.5-.5)+.5;
if (JDay >= NMM && JDay< NMM2) {
MoonAge=JDay-NMM;
SynodicF=MoonAge/(NMM2-NMM);
Moon=0
if (MoonAge >= .9) {Moon=10};
if (MoonAge >= 2.5) {Moon=1};
if (MoonAge >= 5.375) {Moon=2};
if (MoonAge >= 8.375) {Moon=3};
if (MoonAge >= 12.75) {Moon=4};
if (MoonAge >= 15.75) {Moon=5};
if (MoonAge >= 20.125) {Moon=6};
if (MoonAge >= 23.125) {Moon=7};
if (MoonAge >= 27.5) {Moon=0};};
return NM;
}
function AhBh(year,Calendar) {
if (year<1) {
year=Math.abs(year-1);
//if (Calendar=='Hijri') {year +=' BH'}
//else {year +=' BC'};
}
//else {
//if (Calendar=='Hijri') {year +=' AH'}
//else {
//if (Calendar=='Hebrew') {year +=' AM'}
//else {year +=' AD'};
//}
//}
return year;}
function check() {
if (input!='Jd' && input!='mJd') {
var dlimit=30
if (input=='Gregorian' || input=='Julian') {if (M==1 || M==3 || M==5 || M==7 || M==8 || M==10 || M==12) {dlimit=31}; if (M==2) {dlimit=28+gL(Y)}};
if (Y<1) {return '';};
if (Y>9999) {return '';};
if (Y-Math.floor(Y) != 0) {return ''};
if (M<1) {return '';};
if (M>12) {return '';};
if (M-Math.floor(M) != 0) {return '';};
if (D<1) {return '';};
if (D>dlimit) {return '';}
;}
if (D-Math.floor(D) != 0) {return '';};
return 'ok';
}
function Today() {
var Ndate=new Date();FirstLine="Today";
Y=Ndate.getYear ();M=Ndate.getMonth () +1;;D=Ndate.getDate ();input='Gregorian';W='AD';
if (Y<1970 && Y<70) {Y +=2000} else {if (Y<1970) {Y +=1900}};
Conversion ();
FirstLine="Your Entry";
}
function Toj(Year,Month,Day){
var EPOCH = 2451545.0;
var Extra,Jd;
if (Month <= 2) { --Year;Month += 12;}
Extra=B(Year);
if (input=='Julian') {Extra=0};
Jd=Math.floor(365.25 * (Year + 4712))
+Math.floor(30.6001 * (Month+1))
+ Day + Extra -63.5;
/* J2000d=Jd-EPOCH*/
return Jd;
}
function B(gYear) {
var A = Math.floor(gYear/100);
var b = Math.floor(2-A+(A/4));
return b;
}
var days = new Array();
days[0] = "Sunday";
days[1] = "Monday";
days[2] = "Tuesday";
days[3] = "Wednesday";
days[4] = "Thursday";
days[5] = "Friday";
days[6] = "Saturday";
var months = new Array();
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";
today = new Date();
D=today.getDate();
M=today.getMonth()+1;//this is right even if it is strange
Y=getFullYear(today);
Gragerian2Hijri();
Hm=MonthName(Hm,'Hijri');
//document.write('<font face="Verdana, Arial, Helvetica, sans-serif" size="-2" color="#FFFFFF">');
//document.write(days[today.getDay()]+', '+months[M]+' '+D+', '+Y);
//document.write('</font>');
//document.write(' ');
document.write('<font face="Arial (Arabic)" size="2" color="#FFFFFF">');
document.write('<font color="#838383">ا</font>'+Hd+" "+Hm+" "+Hy);
document.write('</font>');
//-->
</script>