Skip to content

Commit e88d6f7

Browse files
authored
Make public and move getZmanisBasedOffset(double) to parent ZmanimCalendar
1 parent c789a76 commit e88d6f7

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,40 @@ public Instant getPlagHaminchaGRA() {
11121112
public long getShaahZmanisGRA() {
11131113
return getTemporalHour(getSunriseBasedOnElevationSetting(), getSunsetBasedOnElevationSetting());
11141114
}
1115+
1116+
/**
1117+
* A utility method to return <em>alos</em> (dawn) or <em>tzais</em> (dusk) based on a fractional day offset. As an
1118+
* example passing 1.5 to this method as done in the {@link ComprehensiveZmanimCalendar#getTzais90Zmanis()} will return
1119+
* the time 90 minutes <em>zmaniyos</em> after {@link #getSunsetBasedOnElevationSetting()}, a <em>zman</em> known as
1120+
* the <em>achtel zman</em> or 1/8th of the length of the day (12 * 60 = 720-minute day / 8 = 90 or 1.5 hours
1121+
* <em>zmaniyos</em>) after sunset.
1122+
* @param hours the number of <em>shaos zmaniyos</em> (temporal hours) before sunrise or after sunset that defines dawn
1123+
* or dusk. If a negative number is passed in, it will return the time of <em>alos</em> (dawn) (subtracting the
1124+
* time from sunrise) and if a positive number is passed in, it will return the time of <em>tzais</em> (dusk)
1125+
* (adding the time to sunset). If 0 is passed in, a <code>null</code> will be returned (since we can't tell if it
1126+
* is sunrise or sunset based).
1127+
* @return the <code>Instant</code> representing the time. If the calculation can't be computed such as in the Arctic
1128+
* Circle where there is at least one day a year where the sun does not rise, and one where it does not set,
1129+
* a <code>null</code> will be returned. A <code>null</code> will also be returned if 0 is passed in, since we can't
1130+
* tell if it is sunrise or sunset based. See detailed explanation on top of the {@link AstronomicalCalendar}
1131+
* documentation.
1132+
* @see ComprehensiveZmanimCalendar#getTzais72Zmanis()
1133+
* @see ComprehensiveZmanimCalendar#getTzais90Zmanis()
1134+
* @see <a href="{@docRoot}/../search.html?q=ComprehensiveZmanimCalendar%20Zmanis()">...Zmanis() based <em>zmanim</em></a>
1135+
* in the ComprehensiveZmanimCalendar.
1136+
*/
1137+
public Instant getZmanisBasedOffset(double hours) {
1138+
long shaahZmanis = getShaahZmanisGRA();
1139+
if (shaahZmanis == Long.MIN_VALUE || hours == 0) {
1140+
return null;
1141+
}
1142+
1143+
if (hours > 0) {
1144+
return getTimeOffset(getSunsetBasedOnElevationSetting(), (long) (shaahZmanis * hours));
1145+
} else {
1146+
return getTimeOffset(getSunriseBasedOnElevationSetting(), (long) (shaahZmanis * hours));
1147+
}
1148+
}
11151149

11161150
/**
11171151
* A method that returns a <em>shaah zmanis</em> (temporal hour) according to the opinion of the <em><a href=

0 commit comments

Comments
 (0)