diff --git a/time4j-android/src/main/java/net/time4j/calendar/astro/MoonPosition.java b/time4j-android/src/main/java/net/time4j/calendar/astro/MoonPosition.java index 3bcb190..057c0a4 100644 --- a/time4j-android/src/main/java/net/time4j/calendar/astro/MoonPosition.java +++ b/time4j-android/src/main/java/net/time4j/calendar/astro/MoonPosition.java @@ -709,7 +709,7 @@ private static Moment calculateMeeus50( sum += (c * Math.sin(Math.toRadians(arg))); } - return JulianDay.ofEphemerisTime(jde + sum).toMoment(); + return JulianDay.ofEphemerisTime(jde + sum).toMoment().with(Moment.PRECISION, TimeUnit.MINUTES); } @@ -719,18 +719,19 @@ private static Moment anomalistic( ) { // first calculate an approximate anomalistic lunation which is rather too small - PlainDate date = after.toZonalTimestamp(ZonalOffset.UTC).toDate(); + Moment ref = after.with(Moment.PRECISION, TimeUnit.MINUTES); + PlainDate date = ref.toZonalTimestamp(ZonalOffset.UTC).toDate(); double doy = date.getDayOfYear(); int lunation = (int) Math.floor((date.getYear() + (doy / date.lengthOfYear()) - 1999.97) * 13.2555); Moment m = calculateMeeus50(lunation, apogee); - while (m.isBefore(after) || m.isSimultaneous(after)) { + while (!m.isAfter(ref)) { lunation++; m = calculateMeeus50(lunation, apogee); } - return m.with(Moment.PRECISION, TimeUnit.MINUTES); + return m; }