Пример #1
0
        private TimeSpan calcTime( DateTime date, bool rise, double boodkokab )
        {
            try
            {

                Debug.WriteLine(TimeSpan.FromHours(latitude).ToString(), "latitude");
                double[] data = calcTableVal(date, latitude, longitude, daylightadjustment);
                double declination;
                if (rise)
                    declination = data[0];
                else
                    declination = data[1];
                Debug.WriteLine(TimeSpan.FromHours(declination).ToString(), "declination");
                double sunriseset;
                if (rise)
                    sunriseset = data[2];
                else
                    sunriseset = data[3];
                Debug.WriteLine(TimeSpan.FromHours(sunriseset).ToString(), "sunriseset");
                //double boodkokab = TimeSpan.FromHours(108).TotalHours ;
                double boodfoqani = Math.Abs(latitude + (-declination));
                //			if ( (latitude < 0 && declination < 0) || (declination > 0 && latitude > 0) )
                //				boodfoqani = Math.Abs ( latitude ) - Math.Abs ( declination );
                //			else
                //				boodfoqani = Math.Abs ( latitude ) + Math.Abs (declination);
                Debug.WriteLine(TimeSpan.FromHours(boodfoqani).ToString(), "boodfoqani");
                double meezan = boodfoqani + boodkokab;
                double nisfulmajmoo = meezan / 2;
                double hasiltafreeq = boodkokab - nisfulmajmoo;
                double majmoaarba = Math.Log10(1 / Math.Cos(degreesToRadians(Math.Abs(latitude))))
                    + Math.Log10(1 / Math.Cos(degreesToRadians(Math.Abs(declination))))
                    + Math.Log10(Math.Sin(degreesToRadians(Math.Abs(nisfulmajmoo))))
                    + Math.Log10(Math.Sin(degreesToRadians(Math.Abs(hasiltafreeq))));
                Debug.WriteLine(TimeSpan.FromHours(majmoaarba).ToString(), "majmoaarba");
                double jbgroob = 8.0 / 60 * radiansToDegrees(Math.Asin(Math.Pow(10, (majmoaarba + 20) / 2 - 10)));
                Debug.WriteLine(TimeSpan.FromHours(jbgroob).ToString(), "jbgroob");
                double jbtulu = 12 - jbgroob;
                Debug.WriteLine(TimeSpan.FromHours(jbtulu).ToString(), "jbtulu");
                sunriseset = -sunriseset;
                double tadeeltime = TimeSpan.FromMinutes(Math.Abs(longitude) * 4).TotalHours;
                double tadeelmurawaj = Math.Abs(gmtdiff) - tadeeltime;
                Debug.WriteLine(TimeSpan.FromHours(tadeeltime).ToString(), "tadeeltime");
                Debug.WriteLine(TimeSpan.FromHours(tadeelmurawaj).ToString(), "tadeel");
                double time;
                if (rise)
                    time = jbtulu + TimeSpan.FromMinutes(sunriseset).TotalHours;
                else
                    time = jbgroob + TimeSpan.FromMinutes(sunriseset).TotalHours;
                Debug.WriteLine(TimeSpan.FromHours(time).ToString(), "timebeforetadeel");
                time += tadeelmurawaj;
                Debug.WriteLine(TimeSpan.FromHours(time).ToString(), "time");
                return TimeSpan.FromHours(time);
            }
            catch (Exception ex)
            {
                Exceptions.TimeCalculatorException exception = new libpraytt.Exceptions.TimeCalculatorException(ex.Message);
                exception.OriginalException = ex;
                throw exception;

            }
        }
Пример #2
0
        public Hashtable GetFullTimingsForMonth( int month, int yr )
        {
            try
            {
                Hashtable datedata = new Hashtable();
                DateTime startdate = new DateTime(yr, month, 1);
                DateTime stopdate = new DateTime(yr, month + 1, 1);
                for (DateTime date = startdate; date < stopdate; date = date.AddDays(1))
                {
                    TimeListElement time = new TimeListElement();
                    time.Date = date;
                    time.Fajr = calcFajrTime(date);
                    time.Sunrise = calcTuluTime(date);
                    time.Midday = calcZawalTime(date);
                    time.Zuhr = calcZuhrTime(date);
                    time.AsrS = calcAsrSTime(date);
                    time.AsrH = calcAsrHTime(date);
                    time.Sunset = calcMaghribTime(date);
                    time.Isha = calcIshaTime(date);
                    datedata[date.ToShortDateString()] = time;

                }

                //			bool result = false;
                //			lock ( availableYears.SyncRoot )
                //			{
                //				result = availableYears.ContainsKey ( yr.ToString () );
                //			}
                //			if ( result == false )
                //			{
                //				Thread t = PrepareTables ( yr , latitude, latdir, longitude, longdir , daylightadjustment, dltadjsign );
                //				waitForThread ( t , 1000 , 5 , "Time routine for Month : "
                //					+ month.ToString () + " Year : " + yr.ToString() + " timed out." );
                //
                //			}
                //			//lock so that we dont return half-baked data to the client.
                //			Hashtable data;
                //			lock ( availableYears.SyncRoot )
                //			{
                //				data = (Hashtable)availableYears[yr.ToString()];
                //			}
                //			return data;
                return datedata;

            }
            catch (Exception ex)
            {

                Exceptions.TimeCalculatorException exception = new libpraytt.Exceptions.TimeCalculatorException(ex.Message);
                exception.OriginalException = ex;
                throw exception;

            }
        }
Пример #3
0
        private double[] calcTableVal( DateTime date , double latitude, double longitude, double daylightadjustment )
        {
            try
            {
                string longdir = longitude < 0 ? "WEST" : "EAST";
                latitude = Math.Abs(latitude);
                latitude = latitude / 15;
                if (longdir.ToUpper() != "EAST")
                {
                    latitude = -latitude;
                }

                double lo_adjust = 0;
                double timehours = 0;
                double inputdate = date.Day;
                double eotrise = 0;
                double decrise = 0;
                double decset = 0;
                double eotset = 0;
                int monthnum = date.Month;
                for (int aa = 1; aa <= 2; aa++)
                {

                    if (aa == 1)
                        timehours = 6 - latitude;
                    else
                        timehours = 18 - latitude;
                    double timeminutes = 0;
                    double inputminutesaftermidnight = timehours * 60 + timeminutes;
                    double solarminutesaftermidnight = inputminutesaftermidnight + lo_adjust + daylightadjustment;
                    int correctedyear = 0;
                    int correctedmonth = 0;
                    if (monthnum > 2)
                    {
                        correctedyear = date.Year;
                        correctedmonth = monthnum - 3;
                    }

                    else
                    {
                        correctedyear = date.Year - 1;
                        correctedmonth = monthnum + 9;
                    }
                    double t = ((solarminutesaftermidnight / 60.0 / 24.0) + inputdate + Math.Floor(30.6 * correctedmonth + 0.5) + Math.Floor(365.25 * (correctedyear - 1976)) - 8707.5) / 36525.0;
                    double G = 357.528 + 35999.05 * t;
                    G = normalizeto360(G);
                    double C = (1.915 * Math.Sin(G * Math.PI / 180)) + (0.020 * Math.Sin(2.0 * G * Math.PI / 180));
                    double l = 280.460 + (36000.770 * t) + C;
                    l = normalizeto360(l);
                    double alpha = l - 2.466 * Math.Sin(2.0 * l * Math.PI / 180) + 0.053 * Math.Sin(4.0 * l * Math.PI / 180);
                    double eotadjustment = (l - C - alpha) / 15.0 * 60.0;
                    if (aa == 1)
                        eotrise = eotadjustment;
                    else
                        eotset = eotadjustment;
                    double obliquity = 23.4393 - 0.013 * t;
                    double declination = Math.Atan(Math.Tan(obliquity * Math.PI / 180) * Math.Sin(alpha * Math.PI / 180)) * 180 / Math.PI;
                    if (aa == 1)
                        decrise = declination;
                    else
                        decset = declination;

                }

                double[] data = new double[] {
                                               decrise,
                                               decset,
                                               eotrise,
                                               eotset
                                           };

                return data;

            }
            catch (Exception ex)
            {

                Exceptions.TimeCalculatorException exception = new libpraytt.Exceptions.TimeCalculatorException(ex.Message);
                exception.OriginalException = ex;
                throw exception;

            }
        }
Пример #4
0
        public Hashtable GetTimingsForDate( DateTime date )
        {
            try
            {
                Hashtable datedata = new Hashtable();
                TimeListElement time = new TimeListElement();
                time.Date = date;
                time.Fajr = calcFajrTime(date);
                time.Sunrise = calcTuluTime(date);
                time.Midday = calcZawalTime(date);
                time.Zuhr = calcZuhrTime(date);
                time.AsrS = calcAsrSTime(date);
                time.AsrH = calcAsrHTime(date);
                time.Sunset = calcMaghribTime(date);
                time.Isha = calcIshaTime(date);
                datedata[date.ToShortDateString()] = time;
                return datedata;

            }
            catch (Exception ex)
            {

                Exceptions.TimeCalculatorException exception = new libpraytt.Exceptions.TimeCalculatorException(ex.Message);
                exception.OriginalException = ex;
                throw exception;

            }
        }
Пример #5
0
        public Hashtable GetSummaryTimingsForYear( int yr, int granularity  )
        {
            try
            {
                Hashtable datedata = new Hashtable();
                DateTime startdate = new DateTime(yr, 1, 1);
                DateTime stopdate = new DateTime(yr + 1, 1, 1);
                for (DateTime date = startdate; date < stopdate; date = date.AddDays(granularity))
                {
                    TimeListElement time = new TimeListElement();
                    time.Date = date;
                    time.Fajr = calcFajrTime(date);
                    time.Sunrise = calcTuluTime(date);
                    time.Midday = calcZawalTime(date);
                    time.Zuhr = calcZuhrTime(date);
                    time.AsrS = calcAsrSTime(date);
                    time.AsrH = calcAsrHTime(date);
                    time.Sunset = calcMaghribTime(date);
                    time.Isha = calcIshaTime(date);
                    datedata[date.ToShortDateString()] = time;

                }
                return datedata;
            }
            catch (Exception ex)
            {

                Exceptions.TimeCalculatorException exception = new libpraytt.Exceptions.TimeCalculatorException(ex.Message);
                exception.OriginalException = ex;
                throw exception;

            }
        }
Пример #6
0
        public Hashtable GetPrayerTimingsForYear( int yr, Prayers prayer  )
        {
            try
            {
                Hashtable datedata = new Hashtable();
                DateTime startdate = new DateTime(yr, 1, 1);
                DateTime stopdate = new DateTime(yr + 1, 1, 1);
                for (DateTime date = startdate; date < stopdate; date = date.AddDays(1))
                {
                    TimeListElement time = new TimeListElement();
                    time.Date = date;
                    switch (prayer)
                    {
                        case Prayers.Fajr:
                            time.Fajr = calcFajrTime(date);
                            break;
                        case Prayers.Sunrise:
                            time.Sunrise = calcTuluTime(date);
                            break;
                        case Prayers.Midday:
                            time.Midday = calcZawalTime(date);
                            break;
                        case Prayers.Zuhr:
                            time.Zuhr = calcZuhrTime(date);
                            break;
                        case Prayers.AsrS:
                            time.AsrS = calcAsrSTime(date);
                            break;
                        case Prayers.AsrH:
                            time.AsrH = calcAsrHTime(date);
                            break;
                        case Prayers.Sunset:
                            time.Sunset = calcMaghribTime(date);
                            break;
                        case Prayers.Isha:
                            time.Isha = calcIshaTime(date);
                            break;

                    }

                    datedata[date.ToShortDateString()] = time;

                }
                return datedata;

            }
            catch (Exception ex)
            {

                Exceptions.TimeCalculatorException exception = new libpraytt.Exceptions.TimeCalculatorException(ex.Message);
                exception.OriginalException = ex;
                throw exception;

            }
        }
Пример #7
0
        public Hashtable GetPrayerTimingsBetween2(DateTime startdate, DateTime stopdate, Prayers[] prayers, bool summarize, int granularity, ProgressCallback pcb)
        {
            try
            {
                if (!summarize) granularity = 1;
                TimeSpan diff = stopdate - startdate;
                diff.Add(TimeSpan.FromDays(1));
                float progressstep = 100 / (float)diff.Days;
                float progress = 0;
                Hashtable datedata = new Hashtable();
                for (DateTime date = startdate; date <= stopdate; date = date.AddDays(granularity))
                {
                    TimeListElement time = new TimeListElement();
                    time.Date = date;
                    foreach (Prayers p in prayers)
                    {
                        switch (p)
                        {
                            case Prayers.Fajr:
                                time.Fajr = calcFajrTime(date);
                                break;
                            case Prayers.Sunrise:
                                time.Sunrise = calcTuluTime(date);
                                break;
                            case Prayers.Midday:
                                time.Midday = calcZawalTime(date);
                                break;
                            case Prayers.Zuhr:
                                time.Zuhr = calcZuhrTime(date);
                                break;
                            case Prayers.AsrS:
                                time.AsrS = calcAsrSTime(date);
                                break;
                            case Prayers.AsrH:
                                time.AsrH = calcAsrHTime(date);
                                break;
                            case Prayers.Sunset:
                                time.Sunset = calcMaghribTime(date);
                                break;
                            case Prayers.Isha:
                                time.Isha = calcIshaTime(date);
                                break;

                        }
                    }
                    progress += progressstep;
                    pcb((int)progress);
                    datedata[date.ToShortDateString()] = time;
                }
                return datedata;

            }
            catch (Exception ex)
            {
                Exceptions.TimeCalculatorException exception = new libpraytt.Exceptions.TimeCalculatorException(ex.Message);
                exception.OriginalException = ex;
                throw exception;

            }
        }