From e9686018c0271e466e0a5912a831c6c6c2778133 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Thu, 26 Sep 2024 19:38:49 +0200 Subject: [PATCH] Add polar boolean to Twilight and related helper methods --- src/main/java/eu/m724/wtapi/object/Twilight.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/m724/wtapi/object/Twilight.java b/src/main/java/eu/m724/wtapi/object/Twilight.java index 5ea3754..97052c4 100644 --- a/src/main/java/eu/m724/wtapi/object/Twilight.java +++ b/src/main/java/eu/m724/wtapi/object/Twilight.java @@ -8,9 +8,20 @@ import java.time.LocalDateTime; * @param date The date this object contains times for * @param sunrise Time of sunrise * @param sunset Time of sunset + * @param solarNoon Time of solar noon in the current day.
+ * If polar night, the solar noon still applies, because the sun still exists, but doesn't rise above the horizon. + * @param polar Is polar cycle */ -public record Twilight(LocalDate date, LocalDateTime sunrise, LocalDateTime sunset) { +public record Twilight(LocalDate date, LocalDateTime sunrise, LocalDateTime sunset, LocalDateTime solarNoon, boolean polar) { public Duration getDayLength() { return Duration.between(sunrise, sunset); } + + public boolean isPolarNight() { + return polar && Duration.between(sunrise, sunset).isNegative(); + } + + public boolean isPolarDay() { + return polar && !isPolarNight(); + } }