-
Notifications
You must be signed in to change notification settings - Fork 1
/
praytimes-mcwfin.js
1 lines (1 loc) · 7.27 KB
/
praytimes-mcwfin.js
1
function PrayTimes(i){var a,t,n,r,s,e={MWL:{name:"Muslim World League",params:{fajr:18,isha:17}},Egypt:{name:"Egyptian General Authority of Survey",params:{fajr:19.5,isha:17.5}},Makkah:{name:"Umm Al-Qura University, Makkah",params:{fajr:18.5,isha:"90 min"}},Karachi:{name:"University of Islamic Sciences, Karachi",params:{fajr:18,isha:18}},Tehran:{name:"Institute of Geophysics, University of Tehran",params:{fajr:17.7,isha:14,maghrib:4.5,midnight:"Jafari"}},ISNA:{name:"Islamic Society of North America (ISNA)",params:{fajr:15,isha:15}},ISNA_UOIF:{name:"ISNA & UOIF",params:{fajr:15,isha:12}},UOIF:{name:"French Islamic Organization Union",params:{fajr:12,isha:12}},GenShafaq:{name:"MoonSighting Committee Worldwide, Khalid Shaukat",params:{fajr:"0 min",isha:"0 min"}},WhiShafaq:{name:"Maliki, Shafi3i et Hanbali",params:{fajr:"0 min",isha:"0 min"}},RedShafaq:{name:"Maliki, Shafi3i et Hanbali",params:{fajr:"0 min",isha:"0 min"}},Custom:{name:"Maliki, Shafi3i et Hanbali",params:{fajr:0,isha:0}},GenShafaqq:{name:"MoonSighting Committee Worldwide, Khalid Shaukat",params:{}},WhiShafaqq:{name:"Maliki, Shafi3i et Hanbali",params:{}},RedShafaqq:{name:"Maliki, Shafi3i et Hanbali",params:{}},Customm:{name:"Maliki, Shafi3i et Hanbali",params:{}},RED_EQUAT:{name:"Sobh Saddiq et Shafaq Ahmar @ Equator",params:{fajr:"75 min",isha:"62 min"}},WHITE_EQUAT:{name:"Sobh Saddiq et Shafaq Abyad @ Equator",params:{fajr:"75 min",isha:"75 min"}},MCW:{name:"MoonSighting Committee Worldwide, Khalid Shaukat",params:{fajr:13,isha:10}},Jafari:{name:"Shia Ithna-Ashari, Leva Institute, Qum",params:{fajr:16,isha:14,maghrib:4,midnight:"Jafari"}}},h="MWL",u={imsak:"10 min",dhuhr:"0 min",asr:"Standard",highLats:"NightMiddle"},o="24h",m=["am","pm"],f={},c={maghrib:"0 min",midnight:"Standard"};for(var g in e){var d=e[g].params;for(var l in c)void 0===d[l]&&(d[l]=c[l])}d=e[h=e[i]?i:h].params;for(var M in d)u[M]=d[M];for(var g in{imsak:"Imsak",fajr:"Fajr",sunrise:"Sunrise",dhuhr:"Dhuhr",asr:"Asr",sunset:"Sunset",maghrib:"Maghrib",isha:"Isha",midnight:"Midnight"})f[g]=0;return{setMethod:function(i){e[i]&&(this.adjust(e[i].params),h=i)},adjust:function(i){for(var a in i)u[a]=i[a]},tune:function(i){for(var a in i)f[a]=i[a]},getMethod:function(){return h},getSetting:function(){return u},getOffsets:function(){return f},getDefaults:function(){return e},getTimes:function(i,e,h,u,m){return a=1*e[0],t=1*e[1],n=e[2]?1*e[2]:0,o=m||o,i.constructor===Date&&(i=[i.getFullYear(),i.getMonth()+1,i.getDate()]),void 0!==h&&"auto"!=h||(h=this.getTimeZone(i)),void 0!==u&&"auto"!=u||(u=this.getDst(i)),r=1*h+(1*u?1:0),s=this.julian(i[0],i[1],i[2])-t/360,this.computeTimes()},getFormattedTime:function(i,a,t){if(isNaN(i))return"-- : --";if("Float"==a)return i;t=t||m,i=DMath.fixHour(i+.5/60);var n=Math.floor(i),r=Math.floor(60*(i-n)),s="12h"==a?t[n<12?0:1]:"";return("24h"==a?this.twoDigitsFormat(n):(n+12-1)%12+1)+" : "+this.twoDigitsFormat(r)+(s?" "+s:"")},midDay:function(i){var a=this.sunPosition(s+i).equation;return DMath.fixHour(12-a)},sunAngleTime:function(i,t,n){var r=this.sunPosition(s+t).declination,e=this.midDay(t),h=1/15*DMath.arccos((-DMath.sin(i)-DMath.sin(r)*DMath.sin(a))/(DMath.cos(r)*DMath.cos(a)));return e+("ccw"==n?-h:h)},asrTime:function(i,t){var n=this.sunPosition(s+t).declination,r=-DMath.arccot(i+DMath.tan(Math.abs(a-n)));return this.sunAngleTime(r,t)},sunPosition:function(i){var a=i-2451545,t=DMath.fixAngle(357.529+.98560028*a),n=DMath.fixAngle(280.459+.98564736*a),r=DMath.fixAngle(n+1.915*DMath.sin(t)+.02*DMath.sin(2*t)),s=(DMath.cos(t),DMath.cos(2*t),23.439-3.6e-7*a),e=DMath.arctan2(DMath.cos(s)*DMath.sin(r),DMath.cos(r))/15,h=n/15-DMath.fixHour(e);return{declination:DMath.arcsin(DMath.sin(s)*DMath.sin(r)),equation:h}},julian:function(i,a,t){a<=2&&(i-=1,a+=12);var n=Math.floor(i/100),r=2-n+Math.floor(n/4);return Math.floor(365.25*(i+4716))+Math.floor(30.6001*(a+1))+t+r-1524.5},computePrayerTimes:function(i){i=this.dayPortion(i);var a=u,t=this.sunAngleTime(this.eval(a.imsak),i.imsak,"ccw"),n=this.sunAngleTime(this.eval(a.fajr),i.fajr,"ccw"),r=this.sunAngleTime(this.riseSetAngle(),i.sunrise,"ccw");n-=this.sunAngleTime(.833,i.sunrise,"ccw")-r;var s=this.midDay(i.dhuhr),e=this.asrTime(this.asrFactor(a.asr),i.asr),h=this.sunAngleTime(this.riseSetAngle(),i.sunset),o=this.sunAngleTime(this.eval(a.maghrib),i.maghrib),m=this.sunAngleTime(this.eval(a.isha),i.isha);return{imsak:t,fajr:n,sunrise:r,dhuhr:s,asr:e,sunset:h,maghrib:o,isha:m+=h-this.sunAngleTime(.833,i.sunset)}},computeTimes:function(){for(var i={imsak:5,fajr:5,sunrise:6,dhuhr:12,asr:13,sunset:18,maghrib:18,isha:18},a=1;a<=1;a++)i=this.computePrayerTimes(i);return(i=this.adjustTimes(i)).midnight="Jafari"==u.midnight?i.sunset+this.timeDiff(i.sunset,i.fajr)/2:i.sunset+this.timeDiff(i.sunset,i.sunrise)/2,i=this.tuneTimes(i),this.modifyFormats(i)},adjustTimes:function(i){var a=u;for(var n in i)i[n]+=r-t/15;return"None"!=a.highLats&&(i=this.adjustHighLats(i)),this.isMin(a.imsak)&&(i.imsak=i.fajr-this.eval(a.imsak)/60),this.isMin(a.fajr)&&(i.fajr=i.sunrise-this.eval(a.fajr)/60),this.isMin(a.maghrib)&&(i.maghrib=i.sunset+this.eval(a.maghrib)/60),this.isMin(a.isha)&&(i.isha=i.maghrib+this.eval(a.isha)/60),i.dhuhr+=this.eval(a.dhuhr)/60,i},asrFactor:function(i){return{Standard:1,Hanafi:2,Jafari:4/7}[i]||this.eval(i)},riseSetAngle:function(){n<0&&(n=0);return.833+DMath.arccos(6371009/(6371009+n))},tuneTimes:function(i){for(var a in i)i[a]+=f[a]/60;return i},modifyFormats:function(i){for(var a in i)i[a]=this.getFormattedTime(i[a],o);return i},adjustHighLats:function(i){var a=u,t=this.timeDiff(i.sunset,i.sunrise);return i.imsak=this.adjustHLTime(i.imsak,i.sunrise,this.eval(a.imsak),t,"ccw"),i.fajr=this.adjustHLTime(i.fajr,i.sunrise,this.eval(a.fajr),t,"ccw"),i.isha=this.adjustHLTime(i.isha,i.sunset,this.eval(a.isha),t),i.maghrib=this.adjustHLTime(i.maghrib,i.sunset,this.eval(a.maghrib),t),i},adjustHLTime:function(i,a,t,n,r){var s=this.nightPortion(t,n),e="ccw"==r?this.timeDiff(i,a):this.timeDiff(a,i);return(isNaN(i)||e>s)&&(i=a+("ccw"==r?-s:s)),i},nightPortion:function(i,a){var t=u.highLats,n=.5;return"AngleBased"==t&&(n=1/60*i),"OneSeventh"==t&&(n=1/7),"OneSixth"==t&&(n=1/6),"OneFiveth"==t&&(n=.2),n*a},dayPortion:function(i){for(var a in i)i[a]/=24;return i},getTimeZone:function(i){var a=i[0],t=this.gmtOffset([a,0,1]),n=this.gmtOffset([a,6,1]);return Math.min(t,n)},getDst:function(i){return 1*(this.gmtOffset(i)!=this.getTimeZone(i))},gmtOffset:function(i){var a=new Date(i[0],i[1]-1,i[2],12,0,0,0),t=a.toGMTString();return(a-new Date(t.substring(0,t.lastIndexOf(" ")-1)))/36e5},eval:function(i){return 1*(i+"").split(/[^0-9.+-]/)[0]},isMin:function(i){return-1!=(i+"").indexOf("min")},timeDiff:function(i,a){return DMath.fixHour(a-i)},twoDigitsFormat:function(i){return i<10?"0"+i:i}}}var DMath={dtr:function(i){return i*Math.PI/180},rtd:function(i){return 180*i/Math.PI},sin:function(i){return Math.sin(this.dtr(i))},cos:function(i){return Math.cos(this.dtr(i))},tan:function(i){return Math.tan(this.dtr(i))},arcsin:function(i){return this.rtd(Math.asin(i))},arccos:function(i){return this.rtd(Math.acos(i))},arctan:function(i){return this.rtd(Math.atan(i))},arccot:function(i){return this.rtd(Math.atan(1/i))},arctan2:function(i,a){return this.rtd(Math.atan2(i,a))},fixAngle:function(i){return this.fix(i,360)},fixHour:function(i){return this.fix(i,24)},fix:function(i,a){return(i-=a*Math.floor(i/a))<0?i+a:i}},prayTimes=new PrayTimes;