[astro] Added moon phase precision ()

* add more precision to MoonPhase.Age

Signed-off-by: lsiepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2022-12-27 12:56:43 +01:00 committed by GitHub
parent 4a982957c3
commit 35e930c12f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions
bundles/org.openhab.binding.astro/src/main/java/org/openhab/binding/astro/internal

View File

@ -121,7 +121,7 @@ public class MoonCalc {
double julianDateEndOfDay = DateTimeUtils.endOfDayDateToJulianDate(calendar); double julianDateEndOfDay = DateTimeUtils.endOfDayDateToJulianDate(calendar);
double parentNewMoon = getPreviousPhase(calendar, julianDateEndOfDay, NEW_MOON); double parentNewMoon = getPreviousPhase(calendar, julianDateEndOfDay, NEW_MOON);
double age = Math.abs(parentNewMoon - julianDateEndOfDay); double age = Math.abs(parentNewMoon - julianDateEndOfDay);
phase.setAge((int) age); phase.setAge(age);
long parentNewMoonMillis = DateTimeUtils.toCalendar(parentNewMoon).getTimeInMillis(); long parentNewMoonMillis = DateTimeUtils.toCalendar(parentNewMoon).getTimeInMillis();
long ageRangeTimeMillis = phase.getNew().getTimeInMillis() - parentNewMoonMillis; long ageRangeTimeMillis = phase.getNew().getTimeInMillis() - parentNewMoonMillis;

View File

@ -32,7 +32,7 @@ public class MoonPhase {
private Calendar full; private Calendar full;
private Calendar thirdQuarter; private Calendar thirdQuarter;
private Calendar _new; private Calendar _new;
private int age; private double age;
private double illumination; private double illumination;
private double agePercent; private double agePercent;
private double ageDegree; private double ageDegree;
@ -105,7 +105,7 @@ public class MoonPhase {
/** /**
* Sets the age in days. * Sets the age in days.
*/ */
public void setAge(int age) { public void setAge(double age) {
this.age = age; this.age = age;
} }