javascript - Converting Gregorian date to Hijri date -


how convert gregorian dates islamic hijri dates using javascript?

function gmod(n,m){ return ((n%m)+m)%m; }  function kuwaiticalendar(adjust){ var today = new date(); if(adjust) {     adjustmili = 1000*60*60*24*adjust;      todaymili = today.gettime()+adjustmili;     today = new date(todaymili); } day = today.getdate(); month = today.getmonth(); year = today.getfullyear(); m = month+1; y = year; if(m<3) {     y -= 1;     m += 12; }  = math.floor(y/100.); b = 2-a+math.floor(a/4.); if(y<1583) b = 0; if(y==1582) {     if(m>10)  b = -10;     if(m==10) {         b = 0;         if(day>4) b = -10;     } }  jd = math.floor(365.25*(y+4716))+math.floor(30.6001*(m+1))+day+b-1524;  b = 0; if(jd>2299160){     = math.floor((jd-1867216.25)/36524.25);     b = 1+a-math.floor(a/4.); } bb = jd+b+1524; cc = math.floor((bb-122.1)/365.25); dd = math.floor(365.25*cc); ee = math.floor((bb-dd)/30.6001); day =(bb-dd)-math.floor(30.6001*ee); month = ee-1; if(ee>13) {     cc += 1;     month = ee-13; } year = cc-4716;   wd = gmod(jd+1,7)+1;  iyear = 10631./30.; epochastro = 1948084; epochcivil = 1948085;  shift1 = 8.01/60.;  z = jd-epochastro; cyc = math.floor(z/10631.); z = z-10631*cyc; j = math.floor((z-shift1)/iyear); iy = 30*cyc+j; z = z-math.floor(j*iyear+shift1); im = math.floor((z+28.5001)/29.5); if(im==13) im = 12; id = z-math.floor(29.5001*im-29);  var myres = new array(8);  myres[0] = day; //calculated day (ce) myres[1] = month-1; //calculated month (ce) myres[2] = year; //calculated year (ce) myres[3] = jd-1; //julian day number myres[4] = wd-1; //weekday number myres[5] = id; //islamic date myres[6] = im-1; //islamic month myres[7] = iy; //islamic year  return myres; } function writeislamicdate(adjustment) { var wdnames = new array("ahad","ithnin","thulatha","arbaa","khams","jumuah","sabt"); var imonthnames = new array("muharram","safar","rabi'ul awwal","rabi'ul akhir", "jumadal ula","jumadal akhira","rajab","sha'ban", "ramadan","shawwal","dhul qa'ada","dhul hijja"); var idate = kuwaiticalendar(adjustment); var outputislamicdate = wdnames[idate[4]] + ", "  + idate[5] + " " + imonthnames[idate[6]] + " " + idate[7] + " ah"; return outputislamicdate; } 

this converts current computer date hijri. , little modification can achieve snippet change date islamic

document.write(writeislamicdate(1)); 

taken this site


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -