Skip to content

Commit 776042b

Browse files
authored
Tiny change to getInstantFromTime to match the old implementation
The Math.round can at times be a second off. This does not indicate that this way is more accurate. It is simply to allow better comparison to other implementations.
1 parent 853613c commit 776042b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,9 @@ protected Instant getInstantFromTime(double time, SolarEvent solarEvent) {
644644
date = date.minusDays(1);
645645
}
646646
}
647-
LocalDateTime dateTime = date.atStartOfDay().plusNanos(Math.round(time * HOUR_MILLIS) * 1_000_000L);
647+
648+
// Math.round(time * HOUR_MILLIS) * 1_000_000L could be used below, but this exactly matches the pre-3.0 Date-based code.
649+
LocalDateTime dateTime = date.atStartOfDay().plusNanos((long)(time * HOUR_MILLIS) * 1_000_000L);
648650

649651
// The computed time is in UTC fractional hours; anchor in UTC before converting.
650652
return ZonedDateTime.of(dateTime, ZoneOffset.UTC).toInstant();

0 commit comments

Comments
 (0)