Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public class ComprehensiveZmanimCalendar extends ZmanimCalendar {
* @see #getMisheyakir11Point5Degrees()
*/
protected static final double ZENITH_11_POINT_5 = GEOMETRIC_ZENITH + 11.5;

/**
* The zenith of 12.85° below {@link GEOMETRIC_ZENITH geometric zenith} (90°).
* @see #getMisheyakir12Point85Degrees()
Expand Down Expand Up @@ -514,7 +514,11 @@ public long getShaahZmanis96MinutesZmanis() {
* @see #setAteretTorahSunsetOffset(double)
*/
public long getShaahZmanisAteretTorah() {
return getTemporalHour(getAlos72Zmanis(), getTzaisAteretTorah());
ShaahZmanis shaahZmanisTypePrevious = shaahZmanisType;
setShaahZmanisType(ShaahZmanis.GRA);
long result = getTemporalHour(getAlos72Zmanis(), getTzaisAteretTorah());
setShaahZmanisType(shaahZmanisTypePrevious);
return result;
}

/**
Expand Down Expand Up @@ -940,7 +944,7 @@ public Instant getAlos19Degrees() {
public Instant getAlos19Point8Degrees() {
return getSunriseOffsetByDegrees(ZENITH_19_POINT_8);
}

/**
* This method returns <em>misheyakir</em> based on the position of the sun {@link ZENITH_12_POINT_85 12.85°}
* below {@link GEOMETRIC_ZENITH geometric zenith} (90°). This is based on the position of the sun slightly
Expand Down Expand Up @@ -973,7 +977,7 @@ public Instant getAlos19Point8Degrees() {
* hadchak</em></b>. <em>Lechatchila</em>, a later <em>zman</em> should be used. There is no current plan to remove
* this method from the API, and this deprecation is intended to notify developers to add an alert to users of
* the risk of using it.
*
*
* @return The <code>Instant</code> of <em>misheyakir</em>. If the calculation can't be computed such as northern and
* southern locations even south of the Arctic Circle and north of the Antarctic Circle where the sun may
* not reach low enough below the horizon for this calculation, a <code>null</code> will be returned. See
Expand Down Expand Up @@ -1696,7 +1700,7 @@ public Instant getMinchaGedolaAhavatShalom() {
* returned. Since this calculation can be an offset of <em>chatzos</em> (if 30 clock minutes > 1/2 of a <em>shaah
* zmanis</em>), even if {@link #isUseAstronomicalChatzosForOtherZmanim()} is <code>false</code>, this <em>mincha</em>
* time may be affected by {@link #isUseAstronomicalChatzos()}.
*
*
* @param minchaGedola
* the mincha gedola to be compared to {@link #getMinchaGedola30Minutes()}.
* @return the <code>Instant</code> of the later of {@link #getMinchaGedolaGRA()} and {@link #getMinchaGedola30Minutes()}.
Expand All @@ -1706,7 +1710,7 @@ public Instant getMinchaGedolaAhavatShalom() {
* @see #getMinchaGedolaGRA()
* @see #getMinchaGedola30Minutes()
* @see #isUseAstronomicalChatzos()
*
*
*/
public Instant getMinchaGedolaGreaterThan30(Instant minchaGedola) {
if (getMinchaGedola30Minutes() == null || minchaGedola == null) {
Expand All @@ -1716,7 +1720,7 @@ public Instant getMinchaGedolaGreaterThan30(Instant minchaGedola) {
: minchaGedola;
}
}

/**
* This is a convenience method that returns the later of {@link #getMinchaGedolaGRA()} and
* {@link #getMinchaGedola30Minutes()}. In the winter when 1/2 of a {@link #getShaahZmanisGRA() <em>shaah zmanis</em>} is
Expand Down Expand Up @@ -2072,7 +2076,7 @@ public Instant getPlagHamincha18Degrees() {
* <em>shkiah</em>), and if used <em>lekula</em> can result in <em>chillul Shabbos</em> etc. There is no
* current plan to remove this method from the API, and this deprecation is intended to alert developers
* of the danger of using it.
*
*
* @return the <code>Instant</code> of the <em>plag</em>. If the calculation can't be computed such as northern and southern
* locations even south of the Arctic Circle and north of the Antarctic Circle where the sun may not reach
* low enough below the horizon for this calculation, a <code>null</code> will be returned. See detailed
Expand Down Expand Up @@ -2149,7 +2153,7 @@ public Instant getPlagAhavatShalom() {
* Arctic Circle and north of the Antarctic Circle where the sun may not reach low enough below the horizon
* for this calculation, a <code>null</code> will be returned. See detailed explanation on top of the
* {@link AstronomicalCalendar} documentation.
*
*
* @see #getBainHashmashosRT58Point5Minutes()
*/
public Instant getBainHashmashosRT13Point24Degrees() {
Expand Down Expand Up @@ -2259,7 +2263,7 @@ public Instant getBainHashmashosYereim18Minutes() {
public Instant getBainHashmashosYereim3Point05Degrees() {
return getSunsetOffsetByDegrees(ZENITH_MINUS_3_POINT_05);
}

/**
* This method returns the beginning of <em>bain hashmashos</em> (twilight) according to the <a href=
* "https://en.wikipedia.org/wiki/Eliezer_ben_Samuel">Yereim (Rabbi Eliezer of Metz)</a> calculated as 16.875
Expand Down Expand Up @@ -2303,7 +2307,7 @@ public Instant getBainHashmashosYereim16Point875Minutes() {
public Instant getBainHashmashosYereim2Point8Degrees() {
return getSunsetOffsetByDegrees(ZENITH_MINUS_2_POINT_8);
}

/**
* This method returns the beginning of <em>bain hashmashos</em> (twilight) according to the <a href=
* "https://en.wikipedia.org/wiki/Eliezer_ben_Samuel">Yereim (Rabbi Eliezer of Metz)</a> calculated as 13.5 minutes
Expand Down Expand Up @@ -2420,7 +2424,7 @@ public Instant getTzaisGeonim5Point95Degrees() {
* This does not cover the 35.28 seconds it takes to walk 49 amos (the <em>heref ayin</em> of <em>bain hashmashos</em>
* of Rav Yosi) at the pace of a 24-minute mil. See {@link #getTzaisGeonim4Point8Degrees()} for a time that covers the
* <em>heref ayin</em>.
*
*
* @return the <code>Instant</code> representing the time when the sun is 4.66° below sea level. If the calculation
* can't be computed such as northern and southern locations even south of the Arctic Circle and north of
* the Antarctic Circle where the sun may not reach low enough below the horizon for this calculation, a
Expand Down Expand Up @@ -2484,7 +2488,7 @@ public Instant getTzaisGeonim4Point42Degrees() {
public Instant getTzaisGeonim4Point8Degrees() {
return getSunsetOffsetByDegrees(ZENITH_4_POINT_8);
}

/**
* This method returns the <em>tzais</em> (nightfall) based on the opinion of the <em>Geonim</em> as calculated by <a href=
* "https://en.wikipedia.org/wiki/Yechiel_Michel_Tucazinsky">Rabbi Yechiel Michel Tucazinsky</a> as the position of
Expand All @@ -2497,7 +2501,7 @@ public Instant getTzaisGeonim4Point8Degrees() {
* should be noted that this differs from the 6.1° / 6.2° calculation for Rabbi Tucazinsky's time as calculated by the
* Hazmanim Bahalacha Vol II chapter 50:7 (page 515). Calculations show that 6.45° at the equinox is 26.5 minutes after
* <em>shkiah</em> <a href="https://kosherjava.com/2022/01/12/equinox-vs-equilux-zmanim-calculations/">around the equinox /
* equilux</a>.
* equilux</a>.
*
* @return the <code>Instant</code> representing the time when the sun is 6.45° below sea level. If the
* calculation can't be computed such as northern and southern locations even south of the Arctic Circle and
Expand Down Expand Up @@ -3056,7 +3060,7 @@ public Instant getFixedLocalChatzosHayom() {
*/
public Instant getSofZmanKidushLevanaBetweenMoldos(Instant alos, Instant tzais) {
JewishCalendar jewishCalendar = new JewishCalendar(getLocalDate());

// Do not calculate for impossible dates, but account for extreme cases. In the extreme case of Rapa Iti in French
// Polynesia on Dec 2027 when kiddush Levana 3 days can be said on <em>Rosh Chodesh</em>, the sof zman Kiddush Levana
// will be on the 12th of the Teves. In the case of Anadyr, Russia on Jan, 2071, sof zman Kiddush Levana between the
Expand Down Expand Up @@ -3156,7 +3160,7 @@ public Instant getSofZmanKidushLevanaBetweenMoldos() {
*/
public Instant getSofZmanKidushLevana15Days(Instant alos, Instant tzais) {
JewishCalendar jewishCalendar = new JewishCalendar(getLocalDate());

// Do not calculate for impossible dates, but account for extreme cases. In the extreme case of Rapa Iti in
// French Polynesia on Dec 2027 when kiddush Levana 3 days can be said on <em>Rosh Chodesh</em>, the sof zman Kiddush
// Levana will be on the 12th of the Teves. in the case of Anadyr, Russia on Jan, 2071, sof zman kiddush levana will
Expand Down Expand Up @@ -3515,7 +3519,7 @@ public Instant getSofZmanBiurChametzMGA16Point1Degrees() {
* According to the Baal Hatanya, <em>shkiah amiti</em>, true (halachic) sunset, is when the top of the
* sun's disk disappears from view at an elevation similar to the mountains of Eretz Yisrael.
* This time is calculated as the point at which the center of the sun's disk is 1.583 degrees below the horizon.
* A method that returns a <em>shaah zmanis</em> ({@link #getTemporalHour(Instant, Instant) temporal hour}) calculated
* A method that returns a <em>shaah zmanis</em> ({@link #getTemporalHour(Instant, Instant) temporal hour}) calculated
* based on the <a href="https://en.wikipedia.org/wiki/Shneur_Zalman_of_Liadi">Baal Hatanya</a>'s <em>netz
* amiti</em> and <em>shkiah amiti</em> using a dip of 1.583° below the sea level horizon. This calculation divides
* the day based on the opinion of the Baal Hatanya that the day runs from {@link #getSunriseBaalHatanya() netz amiti}
Expand Down Expand Up @@ -3717,7 +3721,7 @@ public Instant getPlagHaminchaBaalHatanya() {
public Instant getTzaisBaalHatanya() {
return getSunsetOffsetByDegrees(ZENITH_6_DEGREES);
}

/**
* This method returns <a href="https://en.wikipedia.org/wiki/Moshe_Feinstein">Rav Moshe Feinstein's</a> opinion of the
* calculation of <em>sof zman krias shema</em> (latest time to recite <em>Shema</em> in the morning) according to the
Expand Down Expand Up @@ -3939,7 +3943,7 @@ public Instant getSamuchLeMinchaKetanaGRA() {
}

/**
*
*
* A method for calculating <em>samuch lemincha ketana</em>, / near <em>mincha ketana</em> time that is half an hour before
* {@link #getMinchaKetanaGRA()} or is 9 * <em>shaos zmaniyos</em> (solar hours) after the start of the day, calculated based
* on a day from and ending a day starting at {@link #getMinchaGedola16Point1Degrees() <em>alos</em> 16.1°} and ending
Expand Down Expand Up @@ -3979,7 +3983,7 @@ public Instant getSamuchLeMinchaKetana16Point1Degrees() {
public Instant getSamuchLeMinchaKetana72Minutes() {
return getSamuchLeMinchaKetana(getAlos72Minutes(), getTzais72Minutes(), true);
}

/**
* {@summary A method that returns {@link #getSunsetBasedOnElevationSetting() sunset} if it occurs, or the time that the sun
* is at its westernmost position (azimuth of 270°), if sunset will not occur that day. In Polar regions (the Arctic or Antarctic
Expand All @@ -3993,7 +3997,7 @@ public Instant getSamuchLeMinchaKetana72Minutes() {
* "https://hebrewbooks.org/pdfpager.aspx?req=1401&pgnum=461">רב פעלים – חלק ב׳, סוד ישרים ס׳ ד׳</a>. This time is close to six hours
* after {@link #getSunTransit() astronomical <em>chatzos hayom</em>}, but depending on the time of year and location in the
* Arctic / Antarctic, it can be up to 46 minutes before or after this time.
*
*
* @return sunset if it occurs, or the time that the sun will reach its westernmost position (azimuth 270°), if sunset will
* not occur that day. If there is no sunset this day, and the azimuth 270° will not occur, a <code>null</code> will
* be returned.
Expand All @@ -4008,7 +4012,7 @@ public Instant getSunsetOrWesternmostSolarAzimuth() {
}
return getTimeAtAzimuth(270);
}

/**
* {@summary A method that returns {@link #getSunriseBasedOnElevationSetting() sunrise} if it occurs, or the time that the sun
* is at its easternmost position (azimuth of 90°), if sunrise will not occur that day. In Polar regions (the Arctic or Antarctic
Expand All @@ -4022,7 +4026,7 @@ public Instant getSunsetOrWesternmostSolarAzimuth() {
* "https://hebrewbooks.org/pdfpager.aspx?req=1401&pgnum=461">רב פעלים – חלק ב׳, סוד ישרים ס׳ ד׳</a>. This time is close to six hours
* before {@link #getSunTransit() astronomical <em>chatzos hayom</em>}, but depending on the time of year and location in the
* Arctic / Antarctic, it can be up to 46 minutes before or after this time.
*
*
* @return sunrise if it occurs, or the time that the sun will reach its easternmost position (azimuth 90°), if sunrise will
* not occur that day. If there is no sunrise this day, and the azimuth 90° will not occur, a <code>null</code> will
* be returned.
Expand All @@ -4037,7 +4041,7 @@ public Instant getSunriseOrEasternmostSolarAzimuth() {
}
return getTimeAtAzimuth(90);
}

/**
* @see java.lang.Object#equals(Object)
*/
Expand All @@ -4061,4 +4065,34 @@ public boolean equals(Object object) {
public int hashCode() {
return 37 * super.hashCode() + Double.hashCode(ateretTorahSunsetOffset);
}

@Override
public long getShaahZmanis() {
switch (shaahZmanisType) {
case ATERET:
return getShaahZmanisAteretTorah();
case BAAL_HATANYA:
return getShaahZmanisBaalHatanya();
case DEGREES_16POINT1:
return getShaahZmanis16Point1Degrees();
case DEGREES_18:
return getShaahZmanis18Degrees();
case DEGREES_19POINT8:
return getShaahZmanis19Point8Degrees();
case DEGREES_26:
return getShaahZmanis26Degrees();
case MINUTES_60:
return getShaahZmanis60Minutes();
case MINUTES_72:
return getShaahZmanis72Minutes();
case MINUTES_90:
return getShaahZmanis90Minutes();
case MINUTES_96:
return getShaahZmanis96Minutes();
case MINUTES_120:
return getShaahZmanis120Minutes();
default:
return super.getShaahZmanis();
}
}
}
36 changes: 36 additions & 0 deletions src/main/java/com/kosherjava/zmanim/ShaahZmanis.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.kosherjava.zmanim;

/**
* Enumeration of <em>shaah zmanis</em> (temporal hour).
*
* @author &copy; Moshe Waisberg 2017 - 2024
*/
public enum ShaahZmanis {

/** According to the opinion of the <em>GRA</em> and the <em>Baal Hatanya</em>. */
GRA,
/** According to the opinion of the Magen Avraham. */
MGA,
/** According to the opinion of the Yeshivat Ateret Torah. */
ATERET,
/** According to the opinion of the Baal Hatanya. */
BAAL_HATANYA,
/** Calculated using a dip of 60 minutes. */
MINUTES_60,
/** Calculated using a dip of 72 minutes. */
MINUTES_72,
/** Calculated using a dip of 90 minutes. */
MINUTES_90,
/** Calculated using a dip of 96 minutes. */
MINUTES_96,
/** Calculated using a dip of 120 minutes. */
MINUTES_120,
/** Calculated using a dip of 16.1&deg;. */
DEGREES_16POINT1,
/** Calculated using a dip of 18&deg;. */
DEGREES_18,
/** Calculated using a dip of 19.8&deg;. */
DEGREES_19POINT8,
/** Calculated using a dip of 26&deg;. */
DEGREES_26
}
44 changes: 40 additions & 4 deletions src/main/java/com/kosherjava/zmanim/ZmanimCalendar.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,19 @@
* @author &copy; Eliyahu Hershfeld 2004 - 2026
*/
public class ZmanimCalendar extends AstronomicalCalendar {


/**
* A type that returns a <em>shaah zmanis</em> ( {@link #getTemporalHour(Date, Date) temporal hour}) according to
* the opinion of the <em>GRA</em> and the <em>Baal Hatanya</em>.
*/
public static final int SHAAH_ZMANIS_GRA = 0;
/**
* A type that returns a <em>shaah zmanis</em> (temporal hour) according to the opinion of the Magen Avraham.
*/
public static final int SHAAH_ZMANIS_MGA = 1;

protected ShaahZmanis shaahZmanisType = ShaahZmanis.GRA;

/**
* Is elevation factored in for some <em>zmanim</em> (see {@link isUseElevation()} for additional information).
* @see isUseElevation()
Expand Down Expand Up @@ -261,7 +273,7 @@ public void setUseAstronomicalChatzosForOtherZmanim(boolean useAstronomicalChatz
*/
protected Instant getSunriseBasedOnElevationSetting() {
if (isUseElevation()) {
return super.getSunrise();
return getSunrise();
}
return getSeaLevelSunrise();
}
Expand All @@ -277,7 +289,7 @@ protected Instant getSunriseBasedOnElevationSetting() {
*/
protected Instant getSunsetBasedOnElevationSetting() {
if (isUseElevation()) {
return super.getSunset();
return getSunset();
}
return getSeaLevelSunset();
}
Expand Down Expand Up @@ -1204,7 +1216,7 @@ public long getShaahZmanisGRA() {
* based <em>zmanim</em>.
*/
public Instant getZmanisBasedOffset(double hours) {
long shaahZmanis = getShaahZmanisGRA();
long shaahZmanis = getShaahZmanis();
if (shaahZmanis == Long.MIN_VALUE || hours == 0) {
return null;
}
Expand Down Expand Up @@ -1546,4 +1558,28 @@ public int hashCode() {
return Objects.hash(super.hashCode(), useElevation, useAstronomicalChatzos,
useAstronomicalChatzosForOtherZmanim, Double.hashCode(candleLightingOffset));
}

/**
* A method that returns a <em>shaah zmanis</em> ( {@link #getTemporalHour(Instant, Instant)} temporal hour}).
*
* @return the <code>long</code> millisecond length of a <em>shaah zmanis</em>.
* @see #getShaahZmanisGRA()
*/
public long getShaahZmanis() {
switch (shaahZmanisType) {
case MGA:
return getShaahZmanis72Minutes();
case GRA:
default:
return getShaahZmanisGRA();
}
}

/**
* Set the type of <em>shaah zmanis</em>.
* @param type the type.
*/
public void setShaahZmanisType(ShaahZmanis type) {
shaahZmanisType = type;
}
}
5 changes: 5 additions & 0 deletions src/main/java/com/kosherjava/zmanim/util/GeoLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.TextStyle;
import java.util.TimeZone;

/**
* A class that contains location information such as latitude and longitude required for astronomical calculations. The
Expand Down Expand Up @@ -138,6 +139,10 @@ public GeoLocation(String name, double latitude, double longitude, ZoneId zoneId
this(name, latitude, longitude, 0, zoneId);
}

public GeoLocation(String name, double latitude, double longitude, TimeZone zone) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pnemonic78 ,
V 3.0.0 intentionally moved off may legacy classes in favor of new ones. I do not plan on adding a wrapper to convert the TimeZone to a ZoneId. The developer can do that prior to calling this.

this(name, latitude, longitude, 0, zone.toZoneId());
}

/**
* GeoLocation constructor with parameters for all required fields.
*
Expand Down
Loading
Loading