Ejemplo 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);
        }
Ejemplo n.º 2
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfAngleBased()
 {
     Assert.Equal(3.9474849041733533, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.AngleBased, FajrAngle, Diff));
 }
Ejemplo n.º 3
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfOneSeventhOfNight()
 {
     Assert.Equal(1.691779244645723, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.OneSeventhOfNight, FajrAngle, Diff));
 }
Ejemplo n.º 4
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfMiddleOfNight()
 {
     Assert.Equal(5.92122735626003, AstronomyMath.GetNightFraction(HighLatitudeAdjustment.MiddleOfNight, FajrAngle, Diff));
 }
Ejemplo n.º 5
0
 public void TestGetNightFractionForHighLatitudeAdjustmentOfNoneShouldThrow()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => AstronomyMath.GetNightFraction(HighLatitudeAdjustment.None, FajrAngle, Diff));
 }