Repository navigation
fix: use UTC date for LST calculation - #312
Merged
Merged
Conversation
ClutchplateDude
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LST is off by about 4 minutes (≈1° in RA) for |UTC offset| hours every day, whenever the local date and the UTC date differ:
LST and
_zeroPosRAare only computed when time/date/offset/longitude are set (i.e. on connect), on:SHPand on park. So a connect, park or set-home inside that window leaves the mount ~1° off in RA until the next one. Plate-solve centering usually hides it.Cause
Mount::calculateLst()passes the local date (getLocalDate()) together with the UTC time (getUtcTime()) toSidereal::calculateByDateAndTime(). When the two dates differ, the formula's day count is off by one, which is one day of sidereal drift (0.985647°/day ≈ 3m56.6s).Fix
New pure helper
core::localToUtcDate(localDate, localSecondsOfDay, utcOffsetHours)incore/CalendarMath. It works out the day shift (−1/0/+1) from the local time of day minus the UTC offset and applies it with the existingcore::addDays().calculateLst()now passes that UTC date. The GPS path (calculateByGPS) already uses the UTC date and is unchanged.Testing
9 new unit tests in
unit_tests/test_core/test_calendar.cpp: east/west of UTC inside and outside the window, UTC+0, exactly at UTC midnight, both year boundaries, and a leap day.Bench, ESP32 (OAE V1), site and time set the way ASCOM/OATControl set them (
:Sg/:SG/:SC/:SL),:XGL#compared with IAU GMST at longitude 0:The remaining −7 s is a constant offset of the existing sidereal formula and not part of this change.
Builds for
oaeboardv1andramps.🤖 Generated with Claude Code