Exemplo n.º 1
0
        public Times ApplyOffset(Dictionary<TimeNames, double> offsets)
        {
            var t = new Times(
                Imsak + offsets[TimeNames.Imsak] / 60,
                Fajr + offsets[TimeNames.Fajr] / 60,
                Sunrise + offsets[TimeNames.Sunrise] / 60,
                Dhuhur + offsets[TimeNames.Dhuhur] / 60,
                Asr + offsets[TimeNames.Asr] / 60,
                Sunset + offsets[TimeNames.Sunset] / 60,
                Magrib + offsets[TimeNames.Magrib] / 60,
                Isha + offsets[TimeNames.Isha] / 60);

            return t;
        }
Exemplo n.º 2
0
        public Times ToLongitudePortions(double timezone, double longitude)
        {
            var t = new Times(
                Imsak + timezone - longitude / 15,
                Fajr + timezone - longitude / 15,
                Sunrise + timezone - longitude / 15,
                Dhuhur + timezone - longitude / 15,
                Asr + timezone - longitude / 15,
                Sunset + timezone - longitude / 15,
                Magrib + timezone - longitude / 15,
                Isha + timezone - longitude / 15);

            return t;
        }
Exemplo n.º 3
0
        public Times ToDayPortions()
        {
            var t = new Times(
                Imsak/24,
                Fajr/24,
                Sunrise/24,
                Dhuhur/24,
                Asr/24,
                Sunset/24,
                Magrib/24,
                Isha/24);

            return t;
        }
Exemplo n.º 4
0
        private PrayerTimeDto ComputeTimes()
        {
            var times = new Times(5, 5, 6, 12, 13, 18, 18, 18);

            times = ComputePrayerTimes(times);

            times = AdjustTimes(times);

            // Add midnight time
            times.Midnight = _settings.Midnight == MidnightMethods.Jafari
                                 ? times.Magrib +
                                   TimeDiff(times.Magrib, times.Fajr)/2.0
                                 : times.Sunset +
                                   TimeDiff(times.Sunset, times.Sunrise)/2.0;

            times = TuneTimes(times);

            return ModifyFormats(times);
        }
Exemplo n.º 5
0
 private PrayerTimeDto ModifyFormats(Times times)
 {
     return times.GetFormattedTimes(_timeFormat);
 }
Exemplo n.º 6
0
        private Times ComputePrayerTimes(Times times)
        {
            times = times.ToDayPortions();

            var imsak = SunAngleTime(_settings.Imsak, times.Imsak, Directions.CCW);
            var fajr = SunAngleTime(_settings.Fajr, times.Fajr, Directions.CCW);
            var sunrise = SunAngleTime(RiseSetAngle(), times.Sunrise, Directions.CCW);
            var dhuhur = MidDay(times.Dhuhur);
            var asr = AsrTime(AsrFactor(_settings.AsrJuristic), times.Asr);
            var sunset = SunAngleTime(RiseSetAngle(), times.Sunset);
            var magrib = SunAngleTime(_settings.Magrib, times.Magrib);
            var isha = SunAngleTime(_settings.Isha, times.Isha);

            var t = new Times(imsak, fajr, sunrise, dhuhur, asr, sunset, magrib, isha);
            return t;
        }
Exemplo n.º 7
0
        private Times AdjustHighLatitudes(Times times)
        {
            var nightTime = TimeDiff(times.Sunset, times.Sunrise);

            times.Imsak = AdjustHLTime(times.Imsak, times.Sunrise, _settings.Imsak, nightTime, Directions.CCW);
            times.Fajr = AdjustHLTime(times.Fajr, times.Sunrise, _settings.Fajr, nightTime, Directions.CCW);
            times.Isha = AdjustHLTime(times.Isha, times.Sunset, _settings.Isha, nightTime);
            times.Magrib = AdjustHLTime(times.Magrib, times.Sunset, _settings.Magrib, nightTime);

            return times;
        }
Exemplo n.º 8
0
        private Times AdjustTimes(Times times)
        {
            times = times.ToLongitudePortions(_timezone, _longitude);

            if (_settings.HighLatitudeMethod != HighLatitudeMethods.None)
                times = AdjustHighLatitudes(times);

            if (_settings.IsImsakInMinutes)
                times.Imsak = times.Fajr - _settings.Imsak/60.0;

            if (_settings.IsMagribInMinutes)
                times.Magrib = times.Sunset + _settings.Magrib/60.0;

            if (_settings.IsIshaInMinutes)
                times.Isha = times.Magrib + _settings.Isha/60.0;

            times.Dhuhur += _settings.DhuhurInMinutes/60.0;

            return times;

        }
Exemplo n.º 9
0
        private Times TuneTimes(Times times)
        {
            // Apply offsets to the times
            times = times.ApplyOffset(_offsets);

            return times;
        }