diff --git a/PALib.Tests/PASun.cs b/PALib.Tests/PASun.cs
index 97b0939..fdf674f 100644
--- a/PALib.Tests/PASun.cs
+++ b/PALib.Tests/PASun.cs
@@ -39,9 +39,13 @@ public void SunriseAndSunset()
[Fact]
public void MorningAndEveningTwilight()
{
- var result = _paSun.MorningAndEveningTwilight(7, 9, 1979, false, 0, 0, 52, PATwilightType.Astronomical);
+ Assert.Equal((3, 17, 20, 37, "OK"), _paSun.MorningAndEveningTwilight(7, 9, 1979, false, 0, 0, 52, PATwilightType.Astronomical));
+ }
- Assert.Equal((3, 17, 20, 37, "OK"), result);
+ [Fact]
+ public void EquationOfTime()
+ {
+ Assert.Equal((6, 31.52), _paSun.EquationOfTime(27, 7, 2010));
}
}
}
\ No newline at end of file
diff --git a/PALib/PASun.cs b/PALib/PASun.cs
index 1714fac..ff5ef5e 100644
--- a/PALib/PASun.cs
+++ b/PALib/PASun.cs
@@ -217,5 +217,28 @@ public class PASun
return (amTwilightBeginsHour, amTwilightBeginsMin, pmTwilightEndsHour, pmTwilightEndsMin, status);
}
+
+ ///
+ /// Calculate the equation of time. (The difference between the real Sun time and the mean Sun time.)
+ ///
+ /// Greenwich date (day part)
+ /// Greenwich date (month part)
+ /// Greenwich date (year part)
+ ///
+ /// equation_of_time_min -- equation of time (minute part)
+ /// equation_of_time_sec -- equation of time (seconds part)
+ ///
+ public (double equationOfTimeMin, double equationOfTimeSec) EquationOfTime(double gwdateDay, int gwdateMonth, int gwdateYear)
+ {
+ var sunLongitudeDeg = PAMacros.SunLong(12, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
+ var sunRAHours = PAMacros.DecimalDegreesToDegreeHours(PAMacros.EcRA(sunLongitudeDeg, 0, 0, 0, 0, 0, gwdateDay, gwdateMonth, gwdateYear));
+ var equivalentUTHours = PAMacros.GreenwichSiderealTimeToUniversalTime(sunRAHours, 0, 0, gwdateDay, gwdateMonth, gwdateYear);
+ var equationOfTimeHours = equivalentUTHours - 12;
+
+ var equationOfTimeMin = PAMacros.DecimalHoursMinute(equationOfTimeHours);
+ var equationOfTimeSec = PAMacros.DecimalHoursSecond(equationOfTimeHours);
+
+ return (equationOfTimeMin, equationOfTimeSec);
+ }
}
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 2b0f349..78ca6c0 100644
--- a/README.md
+++ b/README.md
@@ -43,7 +43,7 @@ If you're interested in this topic, please buy the book! It provides far more de
- [x] Calculate -> Sun's distance and angular size
- [x] Calculate -> Local sunrise and sunset
- [x] Calculate -> Morning and evening twilight
-- [ ] Calculate -> Equation of time
+- [x] Calculate -> Equation of time
- [ ] Calculate -> Solar elongation
### Planets