Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[astro] Update real-time Moon Phase Age #18203

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public void setPositionalInfo(Calendar calendar, double latitude, double longitu
*/
private void setMoonPhase(Calendar calendar, Moon moon) {
MoonPhase phase = moon.getPhase();
double julianDateEndOfDay = DateTimeUtils.endOfDayDateToJulianDate(calendar);
double parentNewMoon = getPreviousPhase(calendar, julianDateEndOfDay, NEW_MOON);
double age = Math.abs(parentNewMoon - julianDateEndOfDay);
double julianDate = DateTimeUtils.dateToJulianDate(calendar);
double parentNewMoon = getPreviousPhase(calendar, julianDate, NEW_MOON);
double age = Math.abs(parentNewMoon - julianDate);
phase.setAge(age);

long parentNewMoonMillis = DateTimeUtils.toCalendar(parentNewMoon).getTimeInMillis();
Expand All @@ -129,7 +129,7 @@ private void setMoonPhase(Calendar calendar, Moon moon) {
double agePercent = ageRangeTimeMillis != 0 ? ageCurrentMillis * 100.0 / ageRangeTimeMillis : 0;
phase.setAgePercent(agePercent);
phase.setAgeDegree(3.6 * agePercent);
double illumination = getIllumination(DateTimeUtils.dateToJulianDate(calendar));
double illumination = getIllumination(julianDate);
phase.setIllumination(illumination);
boolean isWaxing = age < (29.530588853 / 2);
if (DateTimeUtils.isSameDay(calendar, phase.getNew())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ public static Calendar endOfDayDate(Calendar calendar) {
return cal;
}

/**
* Returns the end of day julian date from the calendar object.
*/
public static double endOfDayDateToJulianDate(Calendar calendar) {
return dateToJulianDate(endOfDayDate(calendar));
}

/**
* Returns the year of the calendar object as a decimal value.
*/
Expand Down