mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-02-04 11:24:10 +01:00
[astro] Update real-time Moon Phase Age (#18203)
Instead of returning a constant value of the moon phase age relative to the start of the day, return the real-time calculation of the moon phase age on each channel update Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
parent
8e8bb061fb
commit
e7d44c9632
@ -118,9 +118,9 @@ public class MoonCalc {
|
||||
*/
|
||||
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();
|
||||
@ -129,7 +129,7 @@ public class MoonCalc {
|
||||
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())) {
|
||||
|
@ -129,13 +129,6 @@ public class DateTimeUtils {
|
||||
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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user