Esempio n. 1
0
        /// <summary>
        /// Adjust calculated prayer time to high latitude adjustment.
        /// </summary>
        private static double AdjustForHighLatitude(HighLatitudeAdjustment method, double time, double baseTime, double angle, double diff, Direction direction)
        {
            // Compute night fraction and duration.
            var nightFraction = AstronomyMath.GetNightFraction(method, angle, diff);
            var duration      = direction == Direction.Clockwise
                               ? DateTimeMath.ComputeDuration(time, baseTime)
                               : DateTimeMath.ComputeDuration(baseTime, time);

            // Copy reference;
            var newTime = time;

            if (duration > nightFraction)
            {
                var adjustment = direction == Direction.Clockwise ? nightFraction : -nightFraction;
                newTime = baseTime + adjustment;
            }

            return(newTime);
        }
Esempio n. 2
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfAngleBased()
 {
     Assert.Equal(3.9474849041733533, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.AngleBased, FajrAngle, Diff));
 }
Esempio n. 3
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfOneSeventhOfNight()
 {
     Assert.Equal(1.691779244645723, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.OneSeventhOfNight, FajrAngle, Diff));
 }
Esempio n. 4
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfMiddleOfNight()
 {
     Assert.Equal(5.92122735626003, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.MiddleOfNight, FajrAngle, Diff));
 }
Esempio n. 5
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfNoneShouldThrow()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => AstronomyMath.GetNightFraction(HighLatitudeAdjustment.None, FajrAngle, Diff));
 }