Skip to content

Commit

Permalink
Use Math.CopySign in CalendricalCalculationsHelper (dotnet#60776)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebraminio committed Oct 22, 2021
1 parent 3146533 commit 18f3f56
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,16 +224,6 @@ public static double JulianCenturies(double moment)
return (dynamicalMoment - Noon2000Jan01) / DaysInUniformLengthCentury;
}

private static bool IsNegative(double value)
{
return Math.Sign(value) == -1;
}

private static double CopySign(double value, double sign)
{
return (IsNegative(value) == IsNegative(sign)) ? value : -value;
}

// equation-of-time; approximate the difference between apparent solar time and mean solar time
// formal definition is EOT = GHA - GMHA
// GHA is the Greenwich Hour Angle of the apparent (actual) Sun
Expand Down Expand Up @@ -261,7 +251,7 @@ private static double EquationOfTime(double time)

// approximation of equation of time is not valid for dates that are many millennia in the past or future
// thus limited to a half day
return CopySign(Math.Min(Math.Abs(equation), TwelveHours), equation);
return Math.CopySign(Math.Min(Math.Abs(equation), TwelveHours), equation);
}

private static double AsLocalTime(double apparentMidday, double longitude)
Expand Down

0 comments on commit 18f3f56

Please sign in to comment.