Skip to content

Commit a453571

Browse files
authored
Move getSolarMidnight to the AstronomicalCalendar
where is belongs, from the ComplexZmanimCalendar. Thanks @NightScript370
1 parent 7c69f1b commit a453571

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,23 @@ public Date getSunTransit() {
511511
double noon = getAstronomicalCalculator().getUTCNoon(getAdjustedCalendar(), getGeoLocation());
512512
return getDateFromTime(noon, false);
513513
}
514+
515+
/**
516+
* A method that returns "solar" midnight, or the time when the sun is at its <a
517+
* href="https://en.wikipedia.org/wiki/Nadir">nadir</a>. The current calculation is halfway between today and
518+
* tomorrow's {@link #getSunTransit() sun transit}.
519+
*
520+
* @return the <code>Date</code> of astronomical solar midnight. If the calculation can't be computed such as
521+
* when using the {@link com.kosherjava.zmanim.util.SunTimesCalculator USNO calculator} that does not
522+
* support getting solar noon for the Arctic Circle (where there is at least one day a year where the
523+
* sun does not rise, and one where it does not set), a null will be returned. See detailed explanation
524+
* on top of the page.
525+
*/
526+
public Date getSolarMidnight() {
527+
AstronomicalCalendar clonedCal = (AstronomicalCalendar) clone();
528+
clonedCal.getCalendar().add(Calendar.DATE, 1);
529+
return getTimeOffset(getSunTransit(), (clonedCal.getSunTransit().getTime() - getSunTransit().getTime()) / 2);
530+
}
514531

515532
/**
516533
* A method that returns sundial or solar noon. It occurs when the Sun is <a href

0 commit comments

Comments
 (0)