Add polar boolean to Twilight and related helper methods

This commit is contained in:
Minecon724 2024-09-26 19:38:49 +02:00
parent 9ecaefc708
commit e9686018c0
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -8,9 +8,20 @@ import java.time.LocalDateTime;
* @param date The date this object contains times for * @param date The date this object contains times for
* @param sunrise Time of sunrise * @param sunrise Time of sunrise
* @param sunset Time of sunset * @param sunset Time of sunset
* @param solarNoon Time of solar noon in the current day.<br>
* 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() { public Duration getDayLength() {
return Duration.between(sunrise, sunset); return Duration.between(sunrise, sunset);
} }
public boolean isPolarNight() {
return polar && Duration.between(sunrise, sunset).isNegative();
}
public boolean isPolarDay() {
return polar && !isPolarNight();
}
} }