Skip to content

Fix sign error in getSunrise / getSunset methods#51

Open
guillerodriguez wants to merge 1 commit intomikereedell:masterfrom
guillerodriguez:fix/getsunrise-getsunset-zenith-sign
Open

Fix sign error in getSunrise / getSunset methods#51
guillerodriguez wants to merge 1 commit intomikereedell:masterfrom
guillerodriguez:fix/getsunrise-getsunset-zenith-sign

Conversation

@guillerodriguez
Copy link
Copy Markdown

SunriseSunsetCalculator.getSunrise(...) accepts a "degrees below the horizon" parameter, which corresponds to a solar zenith angle of 90 + X degrees.

However, the implementation used the opposite sign to construct the Zenith instance, so a caller would get the time at which the sun reaches X degrees above the horizon, not below. The same problem is also present in the getSunset(...) method.

Fix both by flipping the sign:

new Zenith(90 - degrees) -> new Zenith(90 + degrees)

Fixes: #50

SunriseSunsetCalculator.getSunrise(...) accepts a "degrees below
the horizon" parameter, which corresponds to a solar zenith angle
of 90 + X degrees.

However, the implementation used the opposite sign to construct
the Zenith instance, so a caller would get the time at which the
sun reaches X degrees *above* the horizon, not below. The same
problem is also present in the getSunset(...) method.

Fix both by flipping the sign:

    new Zenith(90 - degrees) -> new Zenith(90 + degrees)

Fixes: mikereedell#50
@guillerodriguez guillerodriguez force-pushed the fix/getsunrise-getsunset-zenith-sign branch from f289005 to 8b8a55a Compare April 27, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SunriseSunsetCalculator.getSunrise/getSunset use wrong sign for degrees parameter

1 participant