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