Add polar boolean to Twilight and related helper methods
This commit is contained in:
parent
9ecaefc708
commit
e9686018c0
1 changed files with 12 additions and 1 deletions
|
@ -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.<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() {
|
||||
return Duration.between(sunrise, sunset);
|
||||
}
|
||||
|
||||
public boolean isPolarNight() {
|
||||
return polar && Duration.between(sunrise, sunset).isNegative();
|
||||
}
|
||||
|
||||
public boolean isPolarDay() {
|
||||
return polar && !isPolarNight();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue