Script Hijriyah

Script Hijriyah

var g, thistory, sDay, sMonth, sWeek, bora, month, day, year, ayear, cyear;
var aDay, aMonth, theYear, HDAY, HMONTH;
var myDay = new Array(7);

myDay[0] = “Sunday”;
myDay[1] = “Monday”;
myDay[2] = “Tuesday”;
myDay[3] = “Wednesday”;
myDay[4] = “Thursday”;
myDay[5] = “Friday”;
myDay[6] = “Saturday”;

var myiDay = new Array(7);

myiDay[0] = “”;
myiDay[1] = “”;
myiDay[2] = “”;
myiDay[3] = “”;
myiDay[4] = “”;
myiDay[5] = “Jummah”;
myiDay[6] = “”;

var sDate = new Date();
var sString;
var sYear;
g = 0;
thistory=1;
bora = “AD”;
sString = sDate.toString();
sYear = parseInt(sString.substring(sString.length-4,sString.length));

/* Untuk merubah penanggalan Hijriah, tinggal ubah saja pada teks :
* sDay = sDate.getDate() – 1;
* Aslinya : sDay = sDate.getDate();
* Jika ada sesuatu yang lain, maka modifikasi saja bagian ini
*
*/

sDay = sDate.getDate()-1;

sMonth = sDate.getMonth() + 1;
sWeek = sDate.getDay();

function check()
{
day=sDay;
month=sMonth;
year=sYear;
var dday=g+day*1
ayear=year;
if (bora==”BC”) {ayear=-year+1}
convert ()
}

function convert () {
var NOTE=”
var hijri=0;
var georgean=1;
if (georgean>0)
{
georgean=0;
var cdays=day*1;
cdays += (month>11) ?30 : 0;
cdays += (month>10) ?31 : 0;
cdays += (month>9) ? 30 : 0;
cdays += (month>8) ? 31 : 0;
cdays += (month>7) ? 31 : 0;
cdays += (month>6) ? 30 : 0;
cdays += (month>5) ? 31 : 0;
cdays += (month>4) ? 30 : 0;
cdays += (month>3) ? 31 : 0;
cdays += (month>2) ? 28 : 0;
cdays += (month>1) ? 31 : 0;
leap=0;cdays +=0;
if (ayear/4 == Math.floor(ayear/4)) {leap=1;}
if (ayear/100 == Math.floor(ayear/100)) {if (ayear/400 != Math.floor(ayear/400)) {leap=0;}}
if (leap==1) {if (month>2) {cdays +=1;}}
if (day>28+leap) {if (month==2) {kill ()}}
myear = ayear*1+cdays/(365+leap);
process1 ();
}
result();
}

function process1()
{
cyear=(myear-621.578082192)/0.97022298;
cyear += Math.floor(Math.abs(cyear)/3000)*30/10631
cday= cyear-Math.floor(cyear);
cyear -= cday;
if ((cday*10631/30)-Math.floor(cday*10631/30)<.5){cday= Math.floor(cday*10631/30) +1} else {cday= Math.floor(cday*10631/30) +2};
test2(cday)
mday=HDAY;cmonth=HMONTH;
if (cmonth==13){cmonth=1;cyear +=1};
var Precise=Pcision(JulianDay(ayear*1,month*1,day*1,19,30,0));
if (mday !=Precise) {if (mday==1 && Precise>28) {cmonth -=1;if (cmonth==0) {cmonth=12;cyear -=1}} else {if (mday>28 && Precise<3) cmonth=”=”13)” cmonth=”1;cyear”>
mday=Precise
if (cyear<1)>
}

function test2 (HdayN) {
var Monthf=29.53058796;
var Gyear=cyear*0.970224044+621.574981435;
var GyearDf= Gyear-Math.floor(Gyear);
Gyear -= GyearDf;
var l=0;
if (Gyear/4 == Math.floor(Gyear/4)) {l=1;} ;
if (Gyear/100 == Math.floor(Gyear/100)) {if (Gyear/400 != Math.floor(Gyear/400)) {l=0;}};
Gday =Math.floor((365+l)*GyearDf)+1;
Gyear +=Gday/(365+l);
var Hyear=(Gyear-621.574981435)/0.970224044;
var Hdayf=Hyear-Math.floor(Hyear),Hday=Hdayf*10631/30+1;
Hmonth=1;HdayF=1
while (HdayF
Hday +=1;HdayF +=1
if (Hday>= Monthf) {Hday=Hday-Monthf;Hmonth +=1};
}
HDAY=Math.floor(Hday)+1;HMONTH=Hmonth;
}

function Pcision(F)
{
var Status=’ok’;
var Dn=0;
var jDn=F;
if (Moon(jDn-1)<=0) {jDn -=1;Dn +=1}
while (Status==’ok’)
{
var Fn=Moon(jDn);var Fn2=Moon(jDn-1);
if (((Fn/Math.abs(Fn))*(Fn2/Math.abs(Fn2)))==1)
{
Dn +=1;jDn -=1;
}
else
{
if (Math.abs(Fn*Fn2)<.2)
{
Status=’End’;
}
else
{
Dn +=1;jDn -=1;
}
}
}
return Dn;
}

function Moon(jd)
{
var T_ = (jd-EPOCH*1)/ 36525.0;
var mE=297.8502042
+ 445267.1115168*T_
– 0.0016300*(T_*T_)
+ (T_*T_*T_)/545868.0
– (T_*T_*T_*T_)/113065000
var mA=134.9634114
+ 477198.8676313*T_
+ 0.0089970*(T_*T_)
+ (T_*T_*T_)/69699.0
– (T_*T_*T_*T_)/863310000.0

var SmA=357.5291092
+ (35999.0502909*T_)
– (0.0001536 *T_*T_)
+ ((T_*T_*T_)/24490000)
var D = r(mE)*1;
var S = r(SmA)*1;
var M = r(mA)*1;
var phaseAngle=180-D-6.289*sin(M)+2.1*sin(S)-1.274*sin(r(2*D)-M)-0.658*sin(2*D);
phaseAngle +=-0.214*sin(2*M);
phaseAngle +=-0.110*sin(1*D)
/** k (46.1) **/
var iF=(1+cos(phaseAngle))/2*(phaseAngle/Math.abs(phaseAngle))
return iF
}

function rad(angle)
{return r(angle)*Math.PI/180}
function sin(angle)
{return Math.sin(rad(angle))}
function cos(angle)
{return Math.cos(rad(angle))}

function r(Input)
{if (Input >=0) {var Output=Input-Math.floor(Input/360)*360} else {var Output=Input-Math.ceil(Input/360)*360+360;}
return Output}

function JulianDay (gYear,gMonth,gDay,gHour,gMinutes,gSeconds)
{
var calendar=’GREGORIAN’
EPOCH = 2451545.0;
if (gMonth <= 2) { –gYear;gMonth += 12;}
var A = Math.floor(gYear/100);
var B=0;
if (calendar == ‘GREGORIAN’) {B =Math.floor( 2 – A + (A / 4))} else {B = 0;}
var dayFraction = (gHour + gMinutes/60.0 + gSeconds/3600.0) / 24.0;
var dayAndTime = gDay + dayFraction;
jd_ =Math.floor(365.25 * (gYear + 4712))+Math.floor(30.6001 * (gMonth+1)) + dayAndTime + B -63.5;
return jd_*1;
}

function result()
{
if (thistory==1)
{
WeekDay ();
if (cyear<0) g=”=”0)” bora=”BH” bora=”BC” g=”=”0)” bora=”AH” bora=”AD”>
yfinale=day+”/”+month+”/”+year+” “;
finale=mday+”/”+cmonth+”/”+Math.abs(cyear)+” “;
theYear = Math.abs(cyear);
thistory=0;
}
}

function WeekDay()
{
if (g==1) {var Dyear=cyear;var Dmonth=cmonth;var Dday=mday} else {var Dyear=year*1;var Dmonth=month*1;var Dday=day*1}
if (bora==”BC” || Dyear<0 dyear=”-Math.abs(Dyear)+1}
var DayCount=0; var L=0
while (Dyear<10000){
if (Dyear/4==Math.floor(Dyear/4)) {L=1} else {L=0};
if (Dyear/100==Math.floor(Dyear/100)) { if (Dyear/400 !=Math.floor(Dyear/400)) {L=0}};
if (Dmonth==14) {DayCount +=365+L} else {
while (Dmonth<13)>
if (Dmonth==1 || Dmonth==3 || Dmonth==5 || Dmonth==7 || Dmonth==8 || Dmonth==10 || Dmonth==12) {var limit=31} else {var limit=30};
if (Dmonth==2) {limit=28+L}
if (Dday==40) {DayCount +=limit} else {while (Dday
Dday +=1;DayCount +=1;}};
Dmonth +=1;Dday=40}};
Dyear +=1; Dmonth=14};

var Dweek=DayCount%7;
if (Dweek==0) {DAY=” (Fri)”};
if (Dweek==6) {DAY=” (Sat)”};
if (Dweek==5) {DAY=” (Sun)”};
if (Dweek==4) {DAY=” (Mon)”};
if (Dweek==3) {DAY=” (Tue)”};
if (Dweek==2) {DAY=” (Wed)”};
if (Dweek==1) {DAY=” (Thu)”};
}

Categories: JavaScript | Tinggalkan komentar

Navigasi pos

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

Blog di WordPress.com.

%d blogger menyukai ini: