function Farsica(){this.timeNames = new Array('اذان صبح','طلوع آفتاب','اذان ظهر','Asr','غروب آفتاب','اذان مغرب','Isha');var lat;var lng;var timeZone;var JDate;this.methodParams = new Array();this.methodParams[0] = new Array(18, 0, 4, 0, 14);} Farsica.prototype.getDatePrayerTimes = function(year, month, day, latitude, longitude, timeZone){this.lat = latitude;this.lng = longitude;this.timeZone = this.efTz(year, month, day, timeZone);this.JDate = this.jlnD(year, month, day)- longitude/ (15* 24);return this.comDt();} Farsica.prototype.fT24 = function(time){if(isNaN(time)){return '-----';} time = this.fxh(time+ 0.5/ 60);var hours = Math.floor(time); var minutes = Math.floor((time- hours)* 60);return this.twDf(hours)+':'+ this.twDf(minutes);} Farsica.prototype.sPn = function(jd){var D = jd - 2451545.0;var g = this.fxg(357.529 + 0.98560028* D);var q = this.fxg(280.459 + 0.98564736* D);var L = this.fxg(q + 1.915* this.dsn(g) + 0.020* this.dsn(2*g));var R = 1.00014 - 0.01671* this.dcs(g) - 0.00014* this.dcs(2*g);var e = 23.439 - 0.00000036* D;var d = this.rtd(Math.asin(this.dsn(e)* this.dsn(L)));var RA = this.dtn(this.dcs(e)* this.dsn(L), this.dcs(L))/ 15;RA = this.fxh(RA); var EqT = q/15 - RA;return new Array(d, EqT);} Farsica.prototype.cMd = function(t){var T = this.sPn(this.JDate+ t)[1];var Z = this.fxh(12- T);return Z;} Farsica.prototype.comT = function(G, t){var D = this.sPn(this.JDate+ t)[0];var Z = this.cMd(t);var V = 1/15* this.rtd(Math.acos((-this.dsn(G)- this.dsn(D)* this.dsn(this.lat)) / (this.dcs(D)* this.dcs(this.lat))));return Z+ (G>90 ? -V : V);} Farsica.prototype.comA = function(step, t){var D = this.sPn(this.JDate+ t)[0];var G = -this.rtd(Math.atan(1/(step+ Math.tan((Math.abs(this.lat-D) * Math.PI) / 180.0))));return this.comT(G, t);} Farsica.prototype.comTs = function(times){var t = this.dyPo(times);var Fajr = this.comT(180- this.methodParams[0][0], t[0]);var Sunrise = this.comT(180- 0.833, t[1]); var Dhuhr = this.cMd(t[2]);var Asr = this.comA(1+ 0, t[3]);var Sunset = this.comT(0.833, t[4]);var Maghrib = this.comT(this.methodParams[0][2], t[5]);var Isha = this.comT(this.methodParams[0][4], t[6]);return new Array(Fajr, Sunrise, Dhuhr, Asr, Sunset, Maghrib, Isha);} Farsica.prototype.comDt = function(){var times = new Array(5, 6, 12, 13, 18, 18, 18);for (var i=1; i<=1; i++){times = this.comTs(times);}times = this.adjT(times);return this.adjTf(times);} Farsica.prototype.adjT = function(times){for (var i=0; i<7; i++){times[i] += this.timeZone- this.lng/ 15;}times[2] += 0/ 60;if (this.methodParams[0][1] == 1){times[5] = times[4]+ this.methodParams[0][2]/ 60;}if (this.methodParams[0][3] == 1){times[6] = times[5]+ this.methodParams[0][4]/ 60;}if (1 != 0){times = this.adjHl(times);}return times;} Farsica.prototype.adjTf = function(times){for (var i=0; i<7; i++){times[i] = this.fT24(times[i]);}return times;} Farsica.prototype.adjHl = function(times){var nightTime = this.tDff(times[4], times[1]);var FajrDiff = 1/2* nightTime;if (isNaN(times[0]) || this.tDff(times[0], times[1]) > FajrDiff) {times[0] = times[1]- FajrDiff;}var IshaAngle = (this.methodParams[0][3] == 0) ? this.methodParams[0][4] : 18;var IshaDiff = 1/2* nightTime;if (isNaN(times[6]) || this.tDff(times[4], times[6]) > IshaDiff) {times[6] = times[4]+ IshaDiff;}var MaghribAngle = (this.methodParams[0][1] == 0) ? this.methodParams[0][2] : 4;var MaghribDiff = 1/2* nightTime;if (isNaN(times[5]) || this.tDff(times[4], times[5]) > MaghribDiff){times[5] = times[4]+ MaghribDiff;}return times;} Farsica.prototype.dyPo = function(times){for (var i=0; i<7; i++){times[i] /= 24;} return times;} Farsica.prototype.tDff = function(time1, time2){return this.fxh(time2- time1);} Farsica.prototype.twDf = function(num){return (num <10) ? '0'+ num : num;} Farsica.prototype.jlnD = function(year, month, day){if (month <= 2){year -= 1;month += 12;}var A = Math.floor(year/ 100);var B = 2- A+ Math.floor(A/ 4);var JD = Math.floor(365.25* (year+ 4716))+ Math.floor(30.6001* (month+ 1))+ day+ B- 1524.5;return JD;} Farsica.prototype.gtTz = function(date){var localDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);var GMTString = localDate.toGMTString();var GMTDate = new Date(GMTString.substring(0, GMTString.lastIndexOf(' ')- 1));var hoursDiff = (localDate- GMTDate) / (1000* 60* 60);return hoursDiff;} Farsica.prototype.efTz = function(year, month, day, timeZone){if (timeZone == null || typeof(timeZone) == 'undefined' || timeZone == 'auto'){timeZone = this.gtTz(new Date(year, month- 1, day));}return 1* timeZone;} Farsica.prototype.dsn = function(d){return Math.sin((d * Math.PI) / 180.0);} Farsica.prototype.dcs = function(d){return Math.cos((d * Math.PI) / 180.0);} Farsica.prototype.dtn = function(y, x){return this.rtd(Math.atan2(y, x));} Farsica.prototype.rtd = function(r){return (r * 180.0) / Math.PI;} Farsica.prototype.fxg = function(a){a = a - 360.0 * (Math.floor(a / 360.0));a = a < 0 ? a + 360.0 : a;return a;} Farsica.prototype.fxh = function(a){a = a - 24.0 * (Math.floor(a / 24.0));a = a < 0 ? a + 24.0 : a;return a;} var farsica = new Farsica();