diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e5dbacdc..b0ea4586 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. diff --git a/.github/workflows/pull_request_worklow.yml b/.github/workflows/pull_request_worklow.yml index c313261b..37e60a04 100644 --- a/.github/workflows/pull_request_worklow.yml +++ b/.github/workflows/pull_request_worklow.yml @@ -1,5 +1,5 @@ name: Run unit tests -on: [pull_request] +on: [push, pull_request] jobs: test: runs-on: ubuntu-latest @@ -14,4 +14,4 @@ jobs: distribution: adopt - name: Run tests - run: mvn test \ No newline at end of file + run: mvn test diff --git a/CHANGELOG.md b/CHANGELOG.md index 50a9d64b..397aa9c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,21 @@ -## [2.4.0](https://github.com/KosherJava/zmanim/compare/2.3.0...master) (2022-11-27) +## [2.6.0](https://github.com/KosherJava/zmanim/compare/2.4.0...master) (future) + + +## [2.5.0](https://github.com/KosherJava/zmanim/compare/2.4.0...2.5.0) (2023-06-09) + +* Update `ComplexZmanimCalendar.getSolarMidnight()` to support astronomocal midnight that works even in the Arctic/Antarctic. +* Add special Shabbasos/Parshiyos Shuva, Shira, Hagadol, Chazon and Nachamu +* Fix isYomTov() should return false on Erev Shavuos. +* Correct spelling of Bein Hashmashos methods the the `ComplexZmanimCalendar` (was missing the second H). +* Various Daf Yomi Yerushalmi fixes including: + * Correct calculation of the _daf_ number. + * Correct the order of transliterated Yerushalmi _masechtos_. + * Correct the Hebrew spelling of the _masechta_ Kilayim. +* * Added number of IS methods such as is `isYomKippur()`, `isSuccos()`, `isPesach()` etc. to the `JewishCalendar` class. +* Add `isAlHanissimRecited(JewishCalendar)` and `isYaalehVeyavoRecited(JewishCalendar)` to the `TefilaRules` class. +* Clarify documentation to explain that isMacharChodesh() Refers to the Haftorah + +## [2.4.0](https://github.com/KosherJava/zmanim/compare/2.3.0...2.4.0) (2022-11-27) * JewishCalendar.getUpcomingParshah() that will return the upcoming _Parsha_ regardless of the day of week. * Change YerushalmiYomiCalculator to return null on Yom Kippur and Tisha Be'Av when there is no Daf. diff --git a/README.md b/README.md index 1e26c59d..05f2149a 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,14 @@ Add the following to your `pom.xml` file: com.kosherjava zmanim - 2.3.0 + 2.4.0 ``` #### Gradle Add the following to your `build.gradle` file: ```groovy -implementation group: 'com.kosherjava', name: 'zmanim', version: '2.3.0' +implementation group: 'com.kosherjava', name: 'zmanim', version: '2.4.0' ``` License @@ -50,6 +50,7 @@ The KosherJava Zmanim API has been ported to: * Python - https://github.com/pinnymz/python-zmanim & https://pypi.org/project/zmanim/ * PHP - https://github.com/zachweix/PhpZmanim/ * Dart / Flutter - https://github.com/yakir8/kosher_dart +* Go - https://github.com/vlipovetskii/go-zmanim Web Api ------------------------ @@ -68,6 +69,7 @@ __While I did my best to get accurate results, please double check before relyin ------------------------ [![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/KosherJava/zmanim?color=eed6af&label=KosherJava&logo=github)](https://search.maven.org/artifact/com.kosherjava/zmanim) [![GitHub](https://img.shields.io/github/license/KosherJava/zmanim?color=eed6af&logo=gnu)](https://github.com/KosherJava/zmanim/blob/master/LICENSE) +[![GitHub last commit](https://img.shields.io/github/last-commit/KosherJava/zmanim?logo=github)](https://github.com/KosherJava/zmanim/commits/master) [![CodeQL](https://github.com/KosherJava/zmanim/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/KosherJava/zmanim/actions/workflows/codeql-analysis.yml) +[![Run unit tests](https://github.com/KosherJava/zmanim/actions/workflows/pull_request_worklow.yml/badge.svg)](https://github.com/KosherJava/zmanim/actions/workflows/pull_request_worklow.yml) [![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/KosherJava/zmanim?logo=snyk)](https://security.snyk.io/vuln/maven?search=KosherJava) -[![GitHub last commit](https://img.shields.io/github/last-commit/KosherJava/zmanim?logo=github)](https://github.com/KosherJava/zmanim/commits/master) diff --git a/pom.xml b/pom.xml index bfba0a2c..5cbb98de 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.kosherjava zmanim - 2.3.0 + 2.6.0-SNAPSHOT KosherJava Zmanim The Zmanim library is an API for a specialized calendar that can calculate different astronomical times @@ -104,7 +104,9 @@ org.apache.maven.plugins maven-compiler-plugin + 3.10.1 + UTF-8 8 8 diff --git a/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java b/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java index 343e276e..80f5edf8 100644 --- a/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/AstronomicalCalendar.java @@ -1,6 +1,6 @@ /* * Zmanim Java API - * Copyright (C) 2004-2022 Eliyahu Hershfeld + * Copyright (C) 2004-2023 Eliyahu Hershfeld * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) @@ -10,7 +10,7 @@ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, * or connect to: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html */ package com.kosherjava.zmanim; @@ -64,7 +64,7 @@ * * * - * @author © Eliyahu Hershfeld 2004 - 2022 + * @author © Eliyahu Hershfeld 2004 - 2023 */ public class AstronomicalCalendar implements Cloneable { @@ -489,11 +489,17 @@ public long getTemporalHour(Date startOfday, Date endOfDay) { } /** - * A method that returns sundial or solar noon. It occurs when the Sun is transiting the celestial meridian. In this class it is - * calculated as halfway between sea level sunrise and sea level sunset, which can be slightly off the real transit - * time due to changes in declination (the lengthening or shortening day). + * A method that returns sundial or solar noon. It occurs when the Sun is transiting the celestial meridian. The calculations used by + * this class depend on the {@link AstronomicalCalculator} used. If this calendar instance is {@link + * #setAstronomicalCalculator(AstronomicalCalculator) set} to use the {@link com.kosherjava.zmanim.util.NOAACalculator} + * (the default) it will calculate astronomical noon. If the calendar instance is to use the + * {@link com.kosherjava.zmanim.util.SunTimesCalculator}, that does not have code to calculate astronomical noon, the + * sun transit is calculated as halfway between sea level sunrise and sea level sunset, which can be slightly off the + * real transit time due to changes in declination (the lengthening or shortening day). See The Definition of Chatzos for details on the proper + * definition of solar noon / midday. * * @return the Date representing Sun's transit. If the calculation can't be computed such as in the * Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does @@ -502,7 +508,8 @@ public long getTemporalHour(Date startOfday, Date endOfDay) { * @see #getTemporalHour() */ public Date getSunTransit() { - return getSunTransit(getSeaLevelSunrise(), getSeaLevelSunset()); + double noon = getAstronomicalCalculator().getUTCNoon(getAdjustedCalendar(), getGeoLocation()); + return getDateFromTime(noon, false); } /** @@ -730,10 +737,10 @@ public AstronomicalCalculator getAstronomicalCalculator() { /** * A method to set the {@link AstronomicalCalculator} used for astronomical calculations. The Zmanim package ships * with a number of different implementations of the abstract {@link AstronomicalCalculator} based on - * different algorithms, including {@link com.kosherjava.zmanim.util.SunTimesCalculator one implementation} based - * on the US Naval Observatory's algorithm, and - * {@link com.kosherjava.zmanim.util.NOAACalculator another} based on NOAA's - * algorithm. This allows easy runtime switching and comparison of different algorithms. + * different algorithms, including the default {@link com.kosherjava.zmanim.util.NOAACalculator} based on NOAA's implementation of Jean Meeus's algorithms as well as {@link + * com.kosherjava.zmanim.util.SunTimesCalculator} based on the US + * Naval Observatory's algorithm,. This allows easy runtime switching and comparison of different algorithms. * * @param astronomicalCalculator * The astronomicalCalculator to set. diff --git a/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java b/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java index f1b97c4e..f2e729f6 100644 --- a/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/ComplexZmanimCalendar.java @@ -1,6 +1,6 @@ /* * Zmanim Java API - * Copyright (C) 2004-2022 Eliyahu Hershfeld + * Copyright (C) 2004-2023 Eliyahu Hershfeld * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) @@ -10,7 +10,7 @@ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, * or connect to: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html */ package com.kosherjava.zmanim; @@ -106,7 +106,7 @@ *

Documentation from the {@link ZmanimCalendar} parent class

* {@inheritDoc} * - * @author © Eliyahu Hershfeld 2004 - 2022 + * @author © Eliyahu Hershfeld 2004 - 2023 */ public class ComplexZmanimCalendar extends ZmanimCalendar { @@ -158,7 +158,7 @@ public class ComplexZmanimCalendar extends ZmanimCalendar { * @todo Hyperlink the proper sources. * * @see #getTzaisGeonim7Point083Degrees() - * @see #getBainHasmashosRT13Point5MinutesBefore7Point083Degrees() + * @see #getBainHashmashosRT13Point5MinutesBefore7Point083Degrees() */ protected static final double ZENITH_7_POINT_083 = GEOMETRIC_ZENITH + 7 + (5.0 / 60); @@ -198,9 +198,9 @@ public class ComplexZmanimCalendar extends ZmanimCalendar { /** * The zenith of 13.24° below {@link #GEOMETRIC_ZENITH geometric zenith} (90°). This calculation is used for * calculating Rabbeinu Tam's bain hashmashos according to some opinions. - * NOTE: See comments on {@link #getBainHasmashosRT13Point24Degrees} for additional details about the degrees. + * NOTE: See comments on {@link #getBainHashmashosRT13Point24Degrees} for additional details about the degrees. * - * @see #getBainHasmashosRT13Point24Degrees + * @see #getBainHashmashosRT13Point24Degrees * */ protected static final double ZENITH_13_POINT_24 = GEOMETRIC_ZENITH + 13.24; @@ -396,7 +396,7 @@ public class ComplexZmanimCalendar extends ZmanimCalendar { * according to the Yereim. As is traditional with degrees below the horizon, this is calculated without refraction * and from the center of the sun. It would be 0.833° less without this. * - * @see #getBainHasmashosYereim2Point1Degrees() + * @see #getBainHashmashosYereim2Point1Degrees() */ protected static final double ZENITH_MINUS_2_POINT_1 = GEOMETRIC_ZENITH - 2.1; @@ -406,7 +406,7 @@ public class ComplexZmanimCalendar extends ZmanimCalendar { * according to the Yereim. As is traditional with degrees below the horizon, this is calculated without refraction * and from the center of the sun. It would be 0.833° less without this. * - * @see #getBainHasmashosYereim2Point8Degrees() + * @see #getBainHashmashosYereim2Point8Degrees() */ protected static final double ZENITH_MINUS_2_POINT_8 = GEOMETRIC_ZENITH - 2.8; @@ -416,7 +416,7 @@ public class ComplexZmanimCalendar extends ZmanimCalendar { * according to the Yereim. As is traditional with degrees below the horizon, this is calculated without refraction * and from the center of the sun. It would be 0.833° less without this. * - * @see #getBainHasmashosYereim3Point05Degrees() + * @see #getBainHashmashosYereim3Point05Degrees() */ protected static final double ZENITH_MINUS_3_POINT_05 = GEOMETRIC_ZENITH - 3.05; @@ -1847,7 +1847,7 @@ public Date getMinchaGedolaAhavatShalom() { * {@link #getMinchaGedola30Minutes()}. In the winter when 1/2 of a {@link #getShaahZmanisGra() shaah zmanis} is * less than 30 minutes {@link #getMinchaGedola30Minutes()} will be returned, otherwise {@link #getMinchaGedola()} * will be returned. - * + * * @return the Date of the later of {@link #getMinchaGedola()} and {@link #getMinchaGedola30Minutes()}. * If the calculation can't be computed such as in the Arctic Circle where there is at least one day a year * where the sun does not rise, and one where it does not set, a null will be returned. See detailed @@ -2241,7 +2241,7 @@ public Date getPlagAhavatShalom() { /** * Method to return the beginning of bain hashmashos of Rabbeinu Tam calculated when the sun is * {@link #ZENITH_13_POINT_24 13.24°} below the western {@link #GEOMETRIC_ZENITH geometric horizon} (90°) - * after sunset. This calculation is based on the same calculation of {@link #getBainHasmashosRT58Point5Minutes() + * after sunset. This calculation is based on the same calculation of {@link #getBainHashmashosRT58Point5Minutes() * bain hashmashos Rabbeinu Tam 58.5 minutes} but uses a degree-based calculation instead of 58.5 exact * minutes. This calculation is based on the position of the sun 58.5 minutes after sunset in Jerusalem around the equinox / equilux, @@ -2260,11 +2260,21 @@ public Date getPlagAhavatShalom() { * {@link AstronomicalCalendar} documentation. * * @see #ZENITH_13_POINT_24 - * @see #getBainHasmashosRT58Point5Minutes() + * @see #getBainHashmashosRT58Point5Minutes() */ - public Date getBainHasmashosRT13Point24Degrees() { + public Date getBainHashmashosRT13Point24Degrees() { return getSunsetOffsetByDegrees(ZENITH_13_POINT_24); } + + + /** + * Misspelled method name that should be {@link #getBainHashmashosRT13Point24Degrees()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosRT13Point24Degrees() { + return getBainHashmashosRT13Point24Degrees(); + } /** * This method returns the beginning of Bain hashmashos of Rabbeinu Tam calculated as a 58.5 @@ -2277,9 +2287,18 @@ public Date getBainHasmashosRT13Point24Degrees() { * documentation. * */ - public Date getBainHasmashosRT58Point5Minutes() { + public Date getBainHashmashosRT58Point5Minutes() { return getTimeOffset(getElevationAdjustedSunset(), 58.5 * MINUTE_MILLIS); } + + /** + * Misspelled method name that should be {@link #getBainHashmashosRT58Point5Minutes()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosRT58Point5Minutes() { + return getBainHashmashosRT58Point5Minutes(); + } /** * This method returns the beginning of bain hashmashos based on the calculation of 13.5 minutes (3/4 of an @@ -2292,9 +2311,18 @@ public Date getBainHasmashosRT58Point5Minutes() { * documentation. * @see #getTzaisGeonim7Point083Degrees() */ - public Date getBainHasmashosRT13Point5MinutesBefore7Point083Degrees() { + public Date getBainHashmashosRT13Point5MinutesBefore7Point083Degrees() { return getTimeOffset(getSunsetOffsetByDegrees(ZENITH_7_POINT_083), -13.5 * MINUTE_MILLIS); } + + /** + * Misspelled method name that should be {@link #getBainHashmashosRT13Point5MinutesBefore7Point083Degrees()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosRT13Point5MinutesBefore7Point083Degrees() { + return getBainHashmashosRT13Point5MinutesBefore7Point083Degrees(); + } /** * This method returns the beginning of bain hashmashos of Rabbeinu Tam calculated according to the @@ -2308,16 +2336,24 @@ public Date getBainHasmashosRT13Point5MinutesBefore7Point083Degrees() { * calculation, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. */ - public Date getBainHasmashosRT2Stars() { + public Date getBainHashmashosRT2Stars() { Date alos19Point8 = getAlos19Point8Degrees(); Date sunrise = getElevationAdjustedSunrise(); if (alos19Point8 == null || sunrise == null) { return null; } - return getTimeOffset(getElevationAdjustedSunset(), (sunrise.getTime() - alos19Point8.getTime()) * (5 / 18d)); } + /** + * Misspelled method name that should be {@link #getBainHashmashosRT2Stars()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosRT2Stars() { + return getBainHashmashosRT2Stars(); + } + /** * This method returns the beginning of bain hashmashos (twilight) according to the Yereim (Rabbi Eliezer of Metz) calculated as 18 minutes @@ -2328,12 +2364,21 @@ public Date getBainHasmashosRT2Stars() { * Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does * not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. - * @see #getBainHasmashosYereim3Point05Degrees() + * @see #getBainHashmashosYereim3Point05Degrees() */ - public Date getBainHasmashosYereim18Minutes() { + public Date getBainHashmashosYereim18Minutes() { return getTimeOffset(getElevationAdjustedSunset(), -18 * MINUTE_MILLIS); } + /** + * Misspelled method name that should be {@link #getBainHashmashosYereim18Minutes()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosYereim18Minutes() { + return getBainHashmashosYereim18Minutes(); + } + /** * This method returns the beginning of bain hashmashos (twilight) according to the Yereim (Rabbi Eliezer of Metz) calculated as the sun's @@ -2359,14 +2404,24 @@ public Date getBainHasmashosYereim18Minutes() { * {@link AstronomicalCalendar} documentation. * * @see #ZENITH_MINUS_3_POINT_05 - * @see #getBainHasmashosYereim18Minutes() - * @see #getBainHasmashosYereim2Point8Degrees() - * @see #getBainHasmashosYereim2Point1Degrees() + * @see #getBainHashmashosYereim18Minutes() + * @see #getBainHashmashosYereim2Point8Degrees() + * @see #getBainHashmashosYereim2Point1Degrees() */ - public Date getBainHasmashosYereim3Point05Degrees() { + public Date getBainHashmashosYereim3Point05Degrees() { return getSunsetOffsetByDegrees(ZENITH_MINUS_3_POINT_05); } + /** + * Misspelled method name that should be {@link #getBainHashmashosYereim3Point05Degrees()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosYereim3Point05Degrees() { + return getBainHashmashosYereim3Point05Degrees(); + } + + /** * This method returns the beginning of bain hashmashos (twilight) according to the Yereim (Rabbi Eliezer of Metz) calculated as 16.875 @@ -2378,12 +2433,21 @@ public Date getBainHasmashosYereim3Point05Degrees() { * not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. * - * @see #getBainHasmashosYereim2Point8Degrees() + * @see #getBainHashmashosYereim2Point8Degrees() */ - public Date getBainHasmashosYereim16Point875Minutes() { + public Date getBainHashmashosYereim16Point875Minutes() { return getTimeOffset(getElevationAdjustedSunset(), -16.875 * MINUTE_MILLIS); } + /** + * Misspelled method name that should be {@link #getBainHashmashosYereim16Point875Minutes()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosYereim16Point875Minutes() { + return getBainHashmashosYereim16Point875Minutes(); + } + /** * This method returns the beginning of bain hashmashos (twilight) according to the Yereim (Rabbi Eliezer of Metz) calculated as the sun's @@ -2392,7 +2456,7 @@ public Date getBainHasmashosYereim16Point875Minutes() { * its position 16.875 minutes or 3/4 of an 18-minute Mil before sunset. According to the Yereim, bain * hashmashos starts 3/4 of a Mil before sunset and tzais or nightfall starts at sunset. * Details, including how the degrees were calculated can be seen in the documentation of - * {@link #getBainHasmashosYereim3Point05Degrees()}. + * {@link #getBainHashmashosYereim3Point05Degrees()}. * * @return the Date of the sun's position 2.8° minutes before sunset. If the calculation can't * be computed such as in the Arctic Circle where there is at least one day a year where the sun does not @@ -2400,14 +2464,24 @@ public Date getBainHasmashosYereim16Point875Minutes() { * {@link AstronomicalCalendar} documentation. * * @see #ZENITH_MINUS_2_POINT_8 - * @see #getBainHasmashosYereim16Point875Minutes() - * @see #getBainHasmashosYereim3Point05Degrees() - * @see #getBainHasmashosYereim2Point1Degrees() + * @see #getBainHashmashosYereim16Point875Minutes() + * @see #getBainHashmashosYereim3Point05Degrees() + * @see #getBainHashmashosYereim2Point1Degrees() */ - public Date getBainHasmashosYereim2Point8Degrees() { + public Date getBainHashmashosYereim2Point8Degrees() { return getSunsetOffsetByDegrees(ZENITH_MINUS_2_POINT_8); } + /** + * Misspelled method name that should be {@link #getBainHashmashosYereim2Point8Degrees()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosYereim2Point8Degrees() { + return getBainHashmashosYereim2Point8Degrees(); + } + + /** * This method returns the beginning of bain hashmashos (twilight) according to the Yereim (Rabbi Eliezer of Metz) calculated as 13.5 minutes @@ -2419,12 +2493,21 @@ public Date getBainHasmashosYereim2Point8Degrees() { * not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. * - * @see #getBainHasmashosYereim2Point1Degrees() + * @see #getBainHashmashosYereim2Point1Degrees() */ - public Date getBainHasmashosYereim13Point5Minutes() { + public Date getBainHashmashosYereim13Point5Minutes() { return getTimeOffset(getElevationAdjustedSunset(), -13.5 * MINUTE_MILLIS); } + /** + * Misspelled method name that should be {@link #getBainHashmashosYereim13Point5Minutes()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosYereim13Point5Minutes() { + return getBainHashmashosYereim13Point5Minutes(); + } + /** * This method returns the beginning of bain hashmashos according to the Yereim (Rabbi Eliezer of Metz) calculated as the sun's @@ -2433,7 +2516,7 @@ public Date getBainHasmashosYereim13Point5Minutes() { * Yerushalayim, its position 13.5 minutes or 3/4 of an 18-minute Mil before sunset. According to the Yereim, * bain hashmashos starts 3/4 of a mil before sunset and tzais or nightfall starts at sunset. * Details, including how the degrees were calculated can be seen in the documentation of - * {@link #getBainHasmashosYereim3Point05Degrees()}. + * {@link #getBainHashmashosYereim3Point05Degrees()}. * * @return the Date of the sun's position 2.1° minutes before sunset. If the calculation can't * be computed such as in the Arctic Circle where there is at least one day a year where the sun does not @@ -2441,14 +2524,23 @@ public Date getBainHasmashosYereim13Point5Minutes() { * {@link AstronomicalCalendar} documentation. * * @see #ZENITH_MINUS_2_POINT_1 - * @see #getBainHasmashosYereim13Point5Minutes() - * @see #getBainHasmashosYereim2Point8Degrees() - * @see #getBainHasmashosYereim3Point05Degrees() + * @see #getBainHashmashosYereim13Point5Minutes() + * @see #getBainHashmashosYereim2Point8Degrees() + * @see #getBainHashmashosYereim3Point05Degrees() */ - public Date getBainHasmashosYereim2Point1Degrees() { + public Date getBainHashmashosYereim2Point1Degrees() { return getSunsetOffsetByDegrees(ZENITH_MINUS_2_POINT_1); } + /** + * Misspelled method name that should be {@link #getBainHashmashosYereim2Point1Degrees()}. + * @return the properly spelled version. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public Date getBainHasmashosYereim2Point1Degrees() { + return getBainHashmashosYereim2Point1Degrees(); + } + /** * This method returns the tzais (nightfall) based on the opinion of the Geonim calculated at the * sun's position at {@link #ZENITH_3_POINT_7 3.7°} below the western horizon. @@ -3705,9 +3797,7 @@ public Date getSofZmanBiurChametzMGA16Point1Degrees() { public Date getSolarMidnight() { ZmanimCalendar clonedCal = (ZmanimCalendar) clone(); clonedCal.getCalendar().add(Calendar.DAY_OF_MONTH, 1); - Date sunset = getSeaLevelSunset(); - Date sunrise = clonedCal.getSeaLevelSunrise(); - return getTimeOffset(sunset, getTemporalHour(sunset, sunrise) * 6); + return getTimeOffset(getChatzos(), (clonedCal.getChatzos().getTime() - getChatzos().getTime()) / 2); } /** @@ -4153,7 +4243,7 @@ public Date getSofZmanTfilaGRASunriseToFixedLocalChatzos() { * in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it * does not set, a null will be returned. See detailed explanation on top of the {@link AstronomicalCalendar} * documentation. - * + * * @see #getMinchaGedola() * @see #getFixedLocalChatzos() * @see #getMinchaKetanaGRAFixedLocalChatzosToSunset diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/Daf.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/Daf.java index 46e34b8c..d01e5d39 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/Daf.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/Daf.java @@ -1,25 +1,25 @@ /* * Zmanim Java API - * Copyright (C) 2011 - 2020 Eliyahu Hershfeld + * Copyright (C) 2011 - 2023 Eliyahu Hershfeld * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, * or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html */ package com.kosherjava.zmanim.hebrewcalendar; /** - * An Object representing a Daf in the Daf Yomi cycle. + * An Object representing a daf (page) in the Daf Yomi cycle. * - * @author © Eliyahu Hershfeld 2011 - 2020 + * @author © Eliyahu Hershfeld 2011 - 2023 */ public class Daf { /** @@ -63,19 +63,19 @@ public class Daf { "\u05E0\u05D3\u05D4" }; /** - * See {@link #getYerushlmiMasechtaTransliterated()}. + * See {@link #getYerushalmiMasechtaTransliterated()}. */ private static String[] masechtosYerushalmiTransliterated = { "Berachos", "Pe'ah", "Demai", "Kilayim", "Shevi'is", "Terumos", "Ma'asros", "Ma'aser Sheni", "Chalah", "Orlah", "Bikurim", "Shabbos", "Eruvin", "Pesachim", "Beitzah", "Rosh Hashanah", "Yoma", "Sukah", "Ta'anis", "Shekalim", "Megilah", "Chagigah", "Moed Katan", "Yevamos", "Kesuvos", "Sotah", "Nedarim", "Nazir", "Gitin", "Kidushin", "Bava Kama", "Bava Metzia", - "Bava Basra", "Sanhedrin", "Makos", "Shevuos", "Avodah Zarah", "Horayos", "Nidah", "No Daf Today" }; + "Bava Basra", "Shevuos", "Makos", "Sanhedrin", "Avodah Zarah", "Horayos", "Nidah", "No Daf Today" }; /** * See {@link #getYerushalmiMasechta()}. */ - private static final String[] masechtosYerushlmi = { "\u05d1\u05e8\u05db\u05d5\u05ea","\u05e4\u05d9\u05d0\u05d4", - "\u05d3\u05de\u05d0\u05d9","\u05db\u05dc\u05d0\u05d9\u05d9\u05dd","\u05e9\u05d1\u05d9\u05e2\u05d9\u05ea", + private static final String[] masechtosYerushalmi = { "\u05d1\u05e8\u05db\u05d5\u05ea","\u05e4\u05d9\u05d0\u05d4", + "\u05d3\u05de\u05d0\u05d9","\u05db\u05dc\u05d0\u05d9\u05dd","\u05e9\u05d1\u05d9\u05e2\u05d9\u05ea", "\u05ea\u05e8\u05d5\u05de\u05d5\u05ea","\u05de\u05e2\u05e9\u05e8\u05d5\u05ea","\u05de\u05e2\u05e9\u05e8 \u05e9\u05e0\u05d9", "\u05d7\u05dc\u05d4","\u05e2\u05d5\u05e8\u05dc\u05d4","\u05d1\u05d9\u05db\u05d5\u05e8\u05d9\u05dd", "\u05e9\u05d1\u05ea","\u05e2\u05d9\u05e8\u05d5\u05d1\u05d9\u05df","\u05e4\u05e1\u05d7\u05d9\u05dd", @@ -90,12 +90,12 @@ public class Daf { "\u05d0\u05d9\u05df \u05d3\u05e3 \u05d4\u05d9\u05d5\u05dd" }; /** - * gets the masechta number of the currently set Daf. The sequence is: Berachos, Shabbos, Eruvin, Pesachim, - * Shekalim, Yoma, Sukkah, Beitzah, Rosh Hashana, Taanis, Megillah, Moed Katan, Chagigah, Yevamos, Kesubos, Nedarim, - * Nazir, Sotah, Gitin, Kiddushin, Bava Kamma, Bava Metzia, Bava Basra, Sanhedrin, Makkos, Shevuos, Avodah Zarah, - * Horiyos, Zevachim, Menachos, Chullin, Bechoros, Arachin, Temurah, Kerisos, Meilah, Kinnim, Tamid, Midos and + * Gets the masechta number of the currently set Daf. The sequence is: Berachos, Shabbos, Eruvin, + * Pesachim, Shekalim, Yoma, Sukkah, Beitzah, Rosh Hashana, Taanis, Megillah, Moed Katan, Chagigah, Yevamos, Kesubos, + * Nedarim, Nazir, Sotah, Gitin, Kiddushin, Bava Kamma, Bava Metzia, Bava Basra, Sanhedrin, Makkos, Shevuos, Avodah + * Zarah, Horiyos, Zevachim, Menachos, Chullin, Bechoros, Arachin, Temurah, Kerisos, Meilah, Kinnim, Tamid, Midos and * Niddah. - * @return the masechtaNumber + * @return the masechtaNumber. * @see #setMasechtaNumber(int) */ public int getMasechtaNumber() { @@ -103,25 +103,25 @@ public int getMasechtaNumber() { } /** - * Set the masechta number in the order of the Daf Yomi. The sequence is: Berachos, Shabbos, Eruvin, Pesachim, + * Set the masechta number in the order of the Daf Yomi. The sequence is: Berachos, Shabbos, Eruvin, Pesachim, * Shekalim, Yoma, Sukkah, Beitzah, Rosh Hashana, Taanis, Megillah, Moed Katan, Chagigah, Yevamos, Kesubos, Nedarim, * Nazir, Sotah, Gitin, Kiddushin, Bava Kamma, Bava Metzia, Bava Basra, Sanhedrin, Makkos, Shevuos, Avodah Zarah, * Horiyos, Zevachim, Menachos, Chullin, Bechoros, Arachin, Temurah, Kerisos, Meilah, Kinnim, Tamid, Midos and * Niddah. * * @param masechtaNumber - * the masechtaNumber in the order of the Daf Yomi to set + * the masechta number in the order of the Daf Yomi to set. */ public void setMasechtaNumber(int masechtaNumber) { this.masechtaNumber = masechtaNumber; } /** - * Constructor that creates a Daf setting the {@link #setMasechtaNumber(int) masechta Number} and - * {@link #setDaf(int) daf Number} + * Constructor that creates a Daf setting the {@link #setMasechtaNumber(int) masechta number} and + * {@link #setDaf(int) daf number}. * - * @param masechtaNumber the masechtaNumber in the order of the Daf Yomi to set - * @param daf the daf (page) number to set + * @param masechtaNumber the masechta number in the order of the Daf Yomi to set as the current masechta. + * @param daf the daf (page) number to set. */ public Daf(int masechtaNumber, int daf) { this.masechtaNumber = masechtaNumber; @@ -129,29 +129,29 @@ public Daf(int masechtaNumber, int daf) { } /** - * Returns the daf (page number) of the Daf Yomi - * @return the daf (page number) of the Daf Yomi + * Returns the daf (page) number of the Daf Yomi. + * @return the daf (page) number of the Daf Yomi. */ public int getDaf() { return daf; } /** - * Sets the daf (page number) of the Daf Yomi - * @param daf the daf (page) number + * Sets the daf (page) number of the Daf Yomi. + * @param daf the daf (page) number. */ public void setDaf(int daf) { this.daf = daf; } /** - * Returns the transliterated name of the masechta (tractate) of the Daf Yomi. The list of mashechtos is: Berachos, - * Shabbos, Eruvin, Pesachim, Shekalim, Yoma, Sukkah, Beitzah, Rosh Hashana, Taanis, Megillah, Moed Katan, Chagigah, - * Yevamos, Kesubos, Nedarim, Nazir, Sotah, Gitin, Kiddushin, Bava Kamma, Bava Metzia, Bava Basra, Sanhedrin, + * Returns the transliterated name of the masechta (tractate) of the Daf Yomi. The list of mashechtos + * is: Berachos, Shabbos, Eruvin, Pesachim, Shekalim, Yoma, Sukkah, Beitzah, Rosh Hashana, Taanis, Megillah, Moed Katan, + * Chagigah, Yevamos, Kesubos, Nedarim, Nazir, Sotah, Gitin, Kiddushin, Bava Kamma, Bava Metzia, Bava Basra, Sanhedrin, * Makkos, Shevuos, Avodah Zarah, Horiyos, Zevachim, Menachos, Chullin, Bechoros, Arachin, Temurah, Kerisos, Meilah, * Kinnim, Tamid, Midos and Niddah. * - * @return the transliterated name of the masechta (tractate) of the Daf Yomi such as Berachos. + * @return the transliterated name of the masechta (tractate) of the Daf Yomi such as Berachos. * @see #setMasechtaTransliterated(String[]) */ public String getMasechtaTransliterated() { @@ -159,10 +159,10 @@ public String getMasechtaTransliterated() { } /** - * Setter method to allow overriding of the default list of masechtos transliterated into into Latin chars. The default - * uses Ashkenazi American English transliteration. + * Setter method to allow overriding of the default list of masechtos transliterated into into Latin chars. + * The default values use Ashkenazi American English transliteration. * - * @param masechtosBavliTransliterated the list of transliterated Bavli masechtos to set. + * @param masechtosBavliTransliterated the list of transliterated Bavli masechtos to set. * @see #getMasechtaTransliterated() */ public void setMasechtaTransliterated(String[] masechtosBavliTransliterated) { @@ -170,7 +170,7 @@ public void setMasechtaTransliterated(String[] masechtosBavliTransliterated) { } /** - * Returns the masechta (tractate) of the Daf Yomi in Hebrew. The list is in the following format
+ * Returns the masechta (tractate) of the Daf Yomi in Hebrew. The list is in the following format
* ["ברכות", * "שבת", "עירובין", * "פסחים", "שקלים", "יומא", @@ -188,7 +188,7 @@ public void setMasechtaTransliterated(String[] masechtosBavliTransliterated) { * "מעילה", "קינים", "תמיד", * "מידות", "נדה"]. * - * @return the masechta (tractate) of the Daf Yomi in Hebrew, It will return + * @return the masechta (tractate) of the Daf Yomi in Hebrew. As an example, it will return * ברכות for Berachos. */ public String getMasechta() { @@ -196,56 +196,96 @@ public String getMasechta() { } /** - * Returns the transliterated name of the masechta (tractate) of the Daf Yomi in Yerushalmi. The list of mashechtos is: - * Berachos, Pe'ah, Demai, Kilayim, Shevi'is, Terumos, Ma'asros, Ma'aser Sheni, Chalah, Orlah, Bikurim, - * Shabbos, Eruvin, Pesachim, Beitzah, Rosh Hashanah, Yoma, Sukah, Ta'anis, Shekalim, Megilah, Chagigah, - * Moed Katan, Yevamos, Kesuvos, Sotah, Nedarim, Nazir, Gitin, Kidushin, Bava Kama, Bava Metzia, - * Bava Basra, Sanhedrin, Makos, Shevuos, Avodah Zarah, Horayos, Nidah and No Daf Today. + * Returns the transliterated name of the masechta (tractate) of the Daf Yomi in Yerushalmi. The list of + * mashechtos is: + * Berachos, Pe'ah, Demai, Kilayim, Shevi'is, Terumos, Ma'asros, Ma'aser Sheni, Chalah, Orlah, Bikurim, + * Shabbos, Eruvin, Pesachim, Beitzah, Rosh Hashanah, Yoma, Sukah, Ta'anis, Shekalim, Megilah, Chagigah, + * Moed Katan, Yevamos, Kesuvos, Sotah, Nedarim, Nazir, Gitin, Kidushin, Bava Kama, Bava Metzia, + * Bava Basra, Shevuos, Makos, Sanhedrin, Avodah Zarah, Horayos, Nidah and No Daf Today. * - * @return the transliterated name of the masechta (tractate) of the Daf Yomi such as Berachos. + * @return the transliterated name of the masechta (tractate) of the Daf Yomi such as Berachos. */ - public String getYerushlmiMasechtaTransliterated() { + public String getYerushalmiMasechtaTransliterated() { return masechtosYerushalmiTransliterated[masechtaNumber]; } /** - * Setter method to allow overriding of the default list of Yerushalmi masechtos transliterated into into Latin chars. + * @see #getYerushalmiMasechtaTransliterated() + * @deprecated misspelled method name to be removed in 3.0.0. + * @return the transliterated name of the masechta (tractate) of the Daf Yomi such as Berachos. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public String getYerushlmiMasechtaTransliterated() { + return getYerushalmiMasechtaTransliterated(); + } + + /** + * Setter method to allow overriding of the default list of Yerushalmi masechtos transliterated into into Latin chars. * The default uses Ashkenazi American English transliteration. * - * @param masechtosYerushalmiTransliterated the list of transliterated Yerushalmi masechtos to set. + * @param masechtosYerushalmiTransliterated the list of transliterated Yerushalmi masechtos to set. */ - public void setYerushlmiMasechtaTransliterated(String[] masechtosYerushalmiTransliterated) { + public void setYerushalmiMasechtaTransliterated(String[] masechtosYerushalmiTransliterated) { Daf.masechtosYerushalmiTransliterated = masechtosYerushalmiTransliterated; } /** - * Getter method to allow retrieving the list of Yerushalmi masechtos transliterated into into Latin chars. + * @see #setYerushalmiMasechtaTransliterated(String[]) + * @deprecated misspelled method name to be removed in 3.0.0. + * @param masechtosYerushalmiTransliterated the list of transliterated Yerushalmi masechtos to set. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public void setYerushlmiMasechtaTransliterated(String[] masechtosYerushalmiTransliterated) { + setYerushalmiMasechtaTransliterated(masechtosYerushalmiTransliterated); + } + + /** + * Getter method to allow retrieving the list of Yerushalmi masechtos transliterated into into Latin chars. * The default uses Ashkenazi American English transliteration. * - * @return the array of transliterated masechta (tractate) names of the Daf Yomi Yerushalmi. + * @return the array of transliterated masechta (tractate) names of the Daf Yomi Yerushalmi. */ - public static String[] getYerushlmiMasechtosTransliterated() { + public static String[] getYerushalmiMasechtosTransliterated() { return masechtosYerushalmiTransliterated; } /** - * Getter method to allow retrieving the list of Yerushalmi masechtos. + * @see #getYerushalmiMasechtosTransliterated() + * @deprecated misspelled method name to be removed in 3.0.0. + * @return the array of transliterated masechta (tractate) names of the Daf Yomi Yerushalmi. + */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version + public static String[] getYerushlmiMasechtosTransliterated() { + return getYerushalmiMasechtosTransliterated(); + } + + /** + * Getter method to allow retrieving the list of Yerushalmi masechtos. * - * @return the array of Hebrew masechta (tractate) names of the Daf Yomi Yerushalmi. + * @return the array of Hebrew masechta (tractate) names of the Daf Yomi Yerushalmi. + */ + public static String[] getYerushalmiMasechtos() { + return masechtosYerushalmi; + } + + /** + * @see #getYerushalmiMasechtos() + * @deprecated misspelled method name to be removed in 3.0.0. + * @return the array of Hebrew masechta (tractate) names of the Daf Yomi Yerushalmi. */ + @Deprecated // (forRemoval=true) // add back once Java 9 is the minimum supported version public static String[] getYerushlmiMasechtos() { - return masechtosYerushlmi; + return getYerushalmiMasechtos(); } /** - * Returns the Yerushlmi masechta (tractate) of the Daf Yomi in Hebrew, It will return + * Returns the Yerushalmi masechta (tractate) of the Daf Yomi in Hebrew. As an example, it will return * ברכות for Berachos. * - * @return the Yerushalmi masechta (tractate) of the Daf Yomi in Hebrew, It will return + * @return the Yerushalmi masechta (tractate) of the Daf Yomi in Hebrew. As an example, it will return * ברכות for Berachos. */ public String getYerushalmiMasechta() { - return masechtosYerushlmi[masechtaNumber]; + return masechtosYerushalmi[masechtaNumber]; } - } diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java index fdf7fdbb..8a81ec95 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java @@ -1,6 +1,6 @@ /* * Zmanim Java API - * Copyright (C) 2011 - 2022 Eliyahu Hershfeld + * Copyright (C) 2011 - 2023 Eliyahu Hershfeld * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) @@ -37,7 +37,7 @@ * @see JewishDate * @see JewishCalendar * - * @author © Eliyahu Hershfeld 2011 - 2022 + * @author © Eliyahu Hershfeld 2011 - 2023 */ public class HebrewDateFormatter { @@ -81,7 +81,7 @@ public class HebrewDateFormatter { * Behar, Bechukosai, Bamidbar, Nasso, Beha'aloscha, Sh'lach, Korach, Chukas, Balak, Pinchas, Matos, Masei, Devarim, * Vaeschanan, Eikev, Re'eh, Shoftim, Ki Seitzei, Ki Savo, Nitzavim, Vayeilech, Ha'Azinu, Vezos Habracha, * Vayakhel Pekudei, Tazria Metzora, Achrei Mos Kedoshim, Behar Bechukosai, Chukas Balak, Matos Masei, Nitzavim Vayeilech, - * Shekalim, Zachor, Parah, Hachodesh". + * Shekalim, Zachor, Parah, Hachodesh,Shuva, Shira, Hagadol, Chazon, Nachamu". * * @see #formatParsha(JewishCalendar) */ @@ -112,7 +112,9 @@ public class HebrewDateFormatter { * קדושים, בהר בחקתי, * חוקת בלק, מטות מסעי, * נצבים וילך, שקלים, - * זכור, פרה, החדש" + * זכור, פרה, החדש, + * שובה,שירה,הגדול, + * חזון,נחמו" */ private EnumMap hebrewParshaMap; @@ -187,6 +189,11 @@ public HebrewDateFormatter() { transliteratedParshaMap.put(JewishCalendar.Parsha.ZACHOR, "Zachor"); transliteratedParshaMap.put(JewishCalendar.Parsha.PARA, "Parah"); transliteratedParshaMap.put(JewishCalendar.Parsha.HACHODESH, "Hachodesh"); + transliteratedParshaMap.put(JewishCalendar.Parsha.SHUVA, "Shuva"); + transliteratedParshaMap.put(JewishCalendar.Parsha.SHIRA, "Shira"); + transliteratedParshaMap.put(JewishCalendar.Parsha.HAGADOL, "Hagadol"); + transliteratedParshaMap.put(JewishCalendar.Parsha.CHAZON, "Chazon"); + transliteratedParshaMap.put(JewishCalendar.Parsha.NACHAMU, "Nachamu"); hebrewParshaMap = new EnumMap(JewishCalendar.Parsha.class); hebrewParshaMap.put(JewishCalendar.Parsha.NONE, ""); @@ -255,6 +262,11 @@ public HebrewDateFormatter() { hebrewParshaMap.put(JewishCalendar.Parsha.ZACHOR, "\u05D6\u05DB\u05D5\u05E8"); hebrewParshaMap.put(JewishCalendar.Parsha.PARA, "\u05E4\u05E8\u05D4"); hebrewParshaMap.put(JewishCalendar.Parsha.HACHODESH, "\u05D4\u05D7\u05D3\u05E9"); + hebrewParshaMap.put(JewishCalendar.Parsha.SHUVA, "\u05E9\u05D5\u05D1\u05D4"); + hebrewParshaMap.put(JewishCalendar.Parsha.SHIRA, "\u05E9\u05D9\u05E8\u05D4"); + hebrewParshaMap.put(JewishCalendar.Parsha.HAGADOL, "\u05D4\u05D2\u05D3\u05D5\u05DC"); + hebrewParshaMap.put(JewishCalendar.Parsha.CHAZON, "\u05D7\u05D6\u05D5\u05DF"); + hebrewParshaMap.put(JewishCalendar.Parsha.NACHAMU, "\u05E0\u05D7\u05DE\u05D5"); } /** diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java index 014b6e76..7eb6212a 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/JewishCalendar.java @@ -1,6 +1,6 @@ /* * Zmanim Java API - * Copyright (C) 2011 - 2022 Eliyahu Hershfeld + * Copyright (C) 2011 - 2023 Eliyahu Hershfeld * Copyright (C) September 2002 Avrom Finkelstien * Copyright (C) 2019 - 2022 Y Paritcher * @@ -42,7 +42,7 @@ * @see java.util.Calendar * @author © Y. Paritcher 2019 - 2022 * @author © Avrom Finkelstien 2002 - * @author © Eliyahu Hershfeld 2011 - 2022 + * @author © Eliyahu Hershfeld 2011 - 2023 */ public class JewishCalendar extends JewishDate { /** The 14th day of Nissan, the day before of Pesach (Passover).*/ @@ -155,6 +155,13 @@ public class JewishCalendar extends JewishDate { */ private boolean inIsrael = false; + /** + * Is the calendar set to have Purim demukafim, where Purim is celebrated on Shushan Purim. + * @see #getIsMukafChoma() + * @see #setIsMukafChoma(boolean) + */ + private boolean isMukafChoma = false; + /** * Is the calendar set to use modern Israeli holidays such as Yom Haatzmaut. * @see #isUseModernHolidays() @@ -163,8 +170,12 @@ public class JewishCalendar extends JewishDate { private boolean useModernHolidays = false; /** - * List of parshiyos. {@link #NONE} indicates a week without a parsha, while the enum for the parsha of - * {@link #VZOS_HABERACHA} exists for consistency, but is not currently used. + * List of parshiyos or special Shabasos. {@link #NONE} indicates a week without a parsha, while the enum for + * the parsha of {@link #VZOS_HABERACHA} exists for consistency, but is not currently used. The special Shabasos of + * Shekalim, Zachor, Para, Hachodesh, as well as Shabbos Shuva, Shira, Hagadol, Chazon and Nachamu are also represented in this collection + * of parshiyos. + * @see #getSpecialShabbos() + * @see #getParshah() */ public static enum Parsha { /**NONE A week without any parsha such as Shabbos Chol Hamoed */NONE, @@ -181,7 +192,8 @@ public static enum Parsha { * of Behar & Bechukosai*/BEHAR_BECHUKOSAI,/**The double parsha of Chukas & Balak*/CHUKAS_BALAK, /**The double * parsha of Matos & Masei*/MATOS_MASEI,/**The double parsha of Nitzavim & Vayelech*/NITZAVIM_VAYEILECH, /**The special parsha of Shekalim*/SHKALIM, /** The special parsha of Zachor*/ZACHOR, /**The special parsha of - * Para*/PARA, /** The special parsha of Hachodesh*/HACHODESH + * Para*/PARA, /** The special parsha of Hachodesh*/HACHODESH, /**Shabbos Shuva*/SHUVA, /**Shabbos Shira*/SHIRA, + /**Shabbos Hagadol*/HAGADOL, /**Shabbos Chazon*/CHAZON, /**Shabbos Nachamu*/NACHAMU }; /** @@ -335,6 +347,28 @@ public boolean getInIsrael() { return inIsrael; } + /** + * Returns if the city is set as a city surrounded by a wall from the time of Yehoshua, and Shushan Purim + * should be celebrated as opposed to regular Purim. + * @return if the city is set as a city surrounded by a wall from the time of Yehoshua, and Shushan Purim + * should be celebrated as opposed to regular Purim. + * @see #setIsMukafChoma(boolean) + */ + public boolean getIsMukafChoma() { + return isMukafChoma; + } + + /** + * Sets if the location is surrounded by a wall from the time of Yehoshua, and Shushan Purim should be + * celebrated as opposed to regular Purim. This should be set for Yerushalayim, Shushan and other cities. + * @param isMukafChoma is the city surrounded by a wall from the time of Yehoshua. + * + * @see #getIsMukafChoma() + */ + public void setIsMukafChoma(boolean isMukafChoma) { + this.isMukafChoma = isMukafChoma; + } + /** * Birkas Hachamah is recited every 28 years based on * Tekufas Shmuel (Julian years) that a year is 365.25 days. The Parsha} enum if the Shabbos is one of the four parshiyos of {@link * Parsha#SHKALIM Shkalim}, {@link Parsha#ZACHOR Zachor}, {@link Parsha#PARA Para}, {@link @@ -506,7 +539,7 @@ public Parsha getUpcomingParshah() { * Parsha#NONE Parsha.NONE}. */ public Parsha getSpecialShabbos() { - if (getDayOfWeek() == Calendar.SATURDAY) { + if (getDayOfWeek() == Calendar.SATURDAY) { if ((getJewishMonth() == SHEVAT && !isJewishLeapYear()) || (getJewishMonth() == ADAR && isJewishLeapYear())) { if (getJewishDayOfMonth() == 25 || getJewishDayOfMonth() == 27 || getJewishDayOfMonth() == 29) { return Parsha.SHKALIM; @@ -526,8 +559,30 @@ public Parsha getSpecialShabbos() { return Parsha.HACHODESH; } } - if (getJewishMonth() == NISSAN && getJewishDayOfMonth() == 1) { - return Parsha.HACHODESH; + if (getJewishMonth() == NISSAN) { + if(getJewishDayOfMonth() == 1) { + return Parsha.HACHODESH; + } + if(getJewishDayOfMonth() >= 8 && getJewishDayOfMonth() <= 14) { + return Parsha.HAGADOL; + } + } + if (getJewishMonth() == AV) { + if(getJewishDayOfMonth() >= 4 && getJewishDayOfMonth() <= 9) { + return Parsha.CHAZON; + } + if(getJewishDayOfMonth() >= 10 && getJewishDayOfMonth() <= 16) { + return Parsha.NACHAMU; + } + } + if (getJewishMonth() == TISHREI) { + if(getJewishDayOfMonth() >= 3 && getJewishDayOfMonth() <= 8) { + return Parsha.SHUVA; + } + + } + if(getParshah() == Parsha.BESHALACH) { + return Parsha.SHIRA; } } return Parsha.NONE; @@ -743,7 +798,7 @@ public int getYomTovIndex() { */ public boolean isYomTov() { int holidayIndex = getYomTovIndex(); - if ((isErevYomTov() && (holidayIndex != HOSHANA_RABBA && (holidayIndex == CHOL_HAMOED_PESACH && getJewishDayOfMonth() != 20))) + if ((isErevYomTov() && (holidayIndex != HOSHANA_RABBA || (holidayIndex == CHOL_HAMOED_PESACH && getJewishDayOfMonth() != 20))) || (isTaanis() && holidayIndex != YOM_KIPPUR) || holidayIndex == ISRU_CHAG) { return false; } @@ -819,31 +874,124 @@ public boolean isErevYomTovSheni() { public boolean isAseresYemeiTeshuva() { return getJewishMonth() == TISHREI && getJewishDayOfMonth() <= 10; } - + /** - * Returns true if the current day is Chol Hamoed of Pesach or Succos. + * Returns true if the current day is Pesach (either the Yom Tov of Pesach orChol Hamoed Pesach). * - * @return true if the current day is Chol Hamoed of Pesach or Succos + * @return true if the current day is Pesach (either the Yom Tov of Pesach orChol Hamoed Pesach). * @see #isYomTov() + * @see #isCholHamoedPesach() + * @see #PESACH * @see #CHOL_HAMOED_PESACH - * @see #CHOL_HAMOED_SUCCOS */ - public boolean isCholHamoed() { - return isCholHamoedPesach() || isCholHamoedSuccos(); + public boolean isPesach() { + int holidayIndex = getYomTovIndex(); + return holidayIndex == PESACH || holidayIndex == CHOL_HAMOED_PESACH; } - + /** * Returns true if the current day is Chol Hamoed of Pesach. * * @return true if the current day is Chol Hamoed of Pesach * @see #isYomTov() + * @see #isPesach() * @see #CHOL_HAMOED_PESACH */ public boolean isCholHamoedPesach() { int holidayIndex = getYomTovIndex(); return holidayIndex == CHOL_HAMOED_PESACH; } - + + /** + * Returns true if the current day is Shavuos. + * + * @return true if the current day is Shavuos. + * @see #isYomTov() + * @see #SHAVUOS + */ + public boolean isShavuos() { + int holidayIndex = getYomTovIndex(); + return holidayIndex == SHAVUOS; + } + + /** + * Returns true if the current day is Rosh Hashana. + * + * @return true if the current day is Rosh Hashana. + * @see #isYomTov() + * @see #ROSH_HASHANA + */ + public boolean isRoshHashana() { + int holidayIndex = getYomTovIndex(); + return holidayIndex == ROSH_HASHANA; + } + + /** + * Returns true if the current day is Yom Kippur. + * + * @return true if the current day is Yom Kippur. + * @see #isYomTov() + * @see #YOM_KIPPUR + */ + public boolean isYomKippur() { + int holidayIndex = getYomTovIndex(); + return holidayIndex == YOM_KIPPUR; + } + + /** + * Returns true if the current day is Succos (either the Yom Tov of Succos orChol Hamoed Succos). + * It will return false for {@link #isShminiAtzeres() Shmini Atzeres} and {@link #isSimchasTorah() Simchas Torah}. + * + * @return true if the current day is Succos (either the Yom Tov of Succos orChol Hamoed Succos. + * @see #isYomTov() + * @see #isCholHamoedSuccos() + * @see #isHoshanaRabba() + * @see #SUCCOS + * @see #CHOL_HAMOED_SUCCOS + * @see #HOSHANA_RABBA + */ + public boolean isSuccos() { + int holidayIndex = getYomTovIndex(); + return holidayIndex == SUCCOS || holidayIndex == CHOL_HAMOED_SUCCOS || holidayIndex == HOSHANA_RABBA; + } + + /** + * Returns true if the current day is Hoshana Rabba. + * + * @return true true if the current day is Hoshana Rabba. + * @see #isYomTov() + * @see #HOSHANA_RABBA + */ + public boolean isHoshanaRabba() { + int holidayIndex = getYomTovIndex(); + return holidayIndex == HOSHANA_RABBA; + } + + /** + * Returns true if the current day is Shmini Atzeres. + * + * @return true if the current day is Shmini Atzeres. + * @see #isYomTov() + * @see #SHEMINI_ATZERES + */ + public boolean isShminiAtzeres() { + int holidayIndex = getYomTovIndex(); + return holidayIndex == SHEMINI_ATZERES; + } + + /** + * Returns true if the current day is Simchas Torah. This will always return false if {@link #getInIsrael() in Israel} + * + * @return true if the current day is Shmini Atzeres. + * @see #isYomTov() + * @see #SIMCHAS_TORAH + */ + public boolean isSimchasTorah() { + int holidayIndex = getYomTovIndex(); + //if in Israel, Holiday index of SIMCHAS_TORAH will not be returned by getYomTovIndex() + return holidayIndex == SIMCHAS_TORAH; + } + /** * Returns true if the current day is Chol Hamoed of Succos. * @@ -853,7 +1001,19 @@ public boolean isCholHamoedPesach() { */ public boolean isCholHamoedSuccos() { int holidayIndex = getYomTovIndex(); - return holidayIndex == CHOL_HAMOED_SUCCOS; + return holidayIndex == CHOL_HAMOED_SUCCOS || holidayIndex == HOSHANA_RABBA; + } + + /** + * Returns true if the current day is Chol Hamoed of Pesach or Succos. + * + * @return true if the current day is Chol Hamoed of Pesach or Succos + * @see #isYomTov() + * @see #CHOL_HAMOED_PESACH + * @see #CHOL_HAMOED_SUCCOS + */ + public boolean isCholHamoed() { + return isCholHamoedPesach() || isCholHamoedSuccos(); } /** @@ -989,6 +1149,22 @@ public int getDayOfChanukah() { public boolean isChanukah() { return getYomTovIndex() == CHANUKAH; } + + /** + * Returns if the day is Purim (Shushan Purim + * in a mukaf choma and regular Purim in a non-mukaf choma). + * @return if the day is Purim (Shushan Purim in a mukaf choma and regular Purin in a non-mukaf choma) + * + * @see #getIsMukafChoma() + * @see #setIsMukafChoma(boolean) + */ + public boolean isPurim() { + if(isMukafChoma) { + return getYomTovIndex() == SHUSHAN_PURIM; + } else { + return getYomTovIndex() == PURIM; + } + } /** * Returns if the day is Rosh Chodesh. Rosh Hashana will return false @@ -1001,9 +1177,9 @@ public boolean isRoshChodesh() { } /** - * Returns if the day is Shabbos and Sunday is Rosh Chodesh. + * Returns if the day is Shabbos and Sunday is Rosh Chodesh and the haftorah of Machar Chodesh is read. * - * @return true if it is Shabbos and Sunday is Rosh Chodesh. + * @return true if it is Shabbos and Sunday is Rosh Chodesh and the haftorah of Machar Chodesh is read. * @todo There is more to tweak in this method (it does not cover all cases and opinions), and it may be removed. */ public boolean isMacharChodesh() { @@ -1041,6 +1217,15 @@ public int getDayOfOmer() { } return omer; } + + /** + * Returns if the day is Tisha Be'Av (the 9th of Av). + * @return if the day is Tisha Be'Av (the 9th of Av). + */ + public boolean isTishaBav() { + int holidayIndex = getYomTovIndex(); + return holidayIndex == TISHA_BEAV; + } /** * Returns the molad in Standard Time in Yerushalayim as a Date. The traditional calculation uses local time. diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TefilaRules.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TefilaRules.java index 7c0f1fb8..d15325f9 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TefilaRules.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TefilaRules.java @@ -372,12 +372,12 @@ public boolean isMoridHatalRecited(JewishCalendar jewishCalendar) { } /** - * Returns if hallel is recited on the day in question. This will return true for both hallel shalem - * and chatzi hallel. See {@link #isHallelShalemRecited(JewishCalendar)} to know if the complete hallel + * Returns if Hallel is recited on the day in question. This will return true for both Hallel shalem + * and Chatzi Hallel. See {@link #isHallelShalemRecited(JewishCalendar)} to know if the complete Hallel * is recited. * * @param jewishCalendar the Jewish calendar day. - * @return if hallel is recited. + * @return if Hallel is recited. * @see #isHallelShalemRecited(JewishCalendar) */ public boolean isHallelRecited(JewishCalendar jewishCalendar) { @@ -440,6 +440,39 @@ public boolean isHallelShalemRecited(JewishCalendar jewishCalendar) { return false; } + /** + * Returns if Al HaNissim is recited on the day in question. + * + * @param jewishCalendar the Jewish calendar day. + * @return if al hanissim is recited. + * @see JewishCalendar#isChanukah() + * @see JewishCalendar#isPurim() + * @see JewishCalendar#getIsMukafChoma() + */ + public boolean isAlHanissimRecited(JewishCalendar jewishCalendar) { + return jewishCalendar.isPurim() || jewishCalendar.isChanukah(); + } + + /** + * Returns if Yaaleh Veyavo is recited on the day in question. + * + * @param jewishCalendar the Jewish calendar day. + * @return if Yaaleh Veyavo is recited. + * @see JewishCalendar#isPesach() + * @see JewishCalendar#isShavuos() + * @see JewishCalendar#isRoshHashana() + * @see JewishCalendar#isYomKippur() + * @see JewishCalendar#isSuccos() + * @see JewishCalendar#isShminiAtzeres() + * @see JewishCalendar#isSimchasTorah() + * @see JewishCalendar#isRoshChodesh() + */ + public boolean isYaalehVeyavoRecited(JewishCalendar jewishCalendar) { + return jewishCalendar.isPesach() || jewishCalendar.isShavuos() ||jewishCalendar.isRoshHashana() || jewishCalendar.isYomKippur() + || jewishCalendar.isSuccos() || jewishCalendar.isShminiAtzeres() || jewishCalendar.isSimchasTorah() + || jewishCalendar.isRoshChodesh(); + } + /** * Is tachanun recited during the week of Purim, from the 11th through the 17th of {@link * JewishDate#ADAR Adar} (on a non-leap year, or {@link JewishDate#ADAR_II Adar II} on a leap year). Some diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YerushalmiYomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YerushalmiYomiCalculator.java index 7a3ba041..301378c3 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YerushalmiYomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/YerushalmiYomiCalculator.java @@ -1,16 +1,16 @@ /* * Zmanim Java API - * Copyright (C) 2017 - 2021 Eliyahu Hershfeld + * Copyright (C) 2017 - 2023 Eliyahu Hershfeld * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, * or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html */ package com.kosherjava.zmanim.hebrewcalendar; @@ -24,7 +24,7 @@ * "https://en.wikipedia.org/wiki/Daf_Yomi">Daf Yomi page ({@link Daf}) for the a given date. * * @author © elihaidv - * @author © Eliyahu Hershfeld 2017 - 2021 + * @author © Eliyahu Hershfeld 2017 - 2023 */ public class YerushalmiYomiCalculator { @@ -37,7 +37,7 @@ public class YerushalmiYomiCalculator { /** The number of pages in the Talmud Yerushalmi.*/ private final static int WHOLE_SHAS_DAFS = 1554; /** The number of pages per masechta (tractate).*/ - private final static int[] BLATT_PER_MASSECTA = { + private final static int[] BLATT_PER_MASECHTA = { 68, 37, 34, 44, 31, 59, 26, 33, 28, 20, 13, 92, 65, 71, 22, 22, 42, 26, 26, 33, 34, 22, 19, 85, 72, 47, 40, 47, 54, 48, 44, 37, 34, 44, 9, 57, 37, 19, 13}; @@ -71,7 +71,7 @@ public static Daf getDafYomiYerushalmi(JewishCalendar calendar) { if (requested.before(DAF_YOMI_START_DAY)) { - throw new IllegalArgumentException(requested + " is prior to organized Daf Yomi Yerushlmi cycles that started on " + throw new IllegalArgumentException(requested + " is prior to organized Daf Yomi Yerushalmi cycles that started on " + DAF_YOMI_START_DAY); } @@ -95,13 +95,13 @@ public static Daf getDafYomiYerushalmi(JewishCalendar calendar) { int total = dafNo - specialDays; // Finally find the daf. - for (int j = 0; j < BLATT_PER_MASSECTA.length; j++) { + for (int j = 0; j < BLATT_PER_MASECHTA.length; j++) { - if (total <= BLATT_PER_MASSECTA[j]) { + if (total < BLATT_PER_MASECHTA[j]) { dafYomi = new Daf(masechta, total + 1); break; } - total -= BLATT_PER_MASSECTA[j]; + total -= BLATT_PER_MASECHTA[j]; masechta++; } diff --git a/src/main/java/com/kosherjava/zmanim/util/AstronomicalCalculator.java b/src/main/java/com/kosherjava/zmanim/util/AstronomicalCalculator.java index f1847a63..72018144 100644 --- a/src/main/java/com/kosherjava/zmanim/util/AstronomicalCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/util/AstronomicalCalculator.java @@ -1,6 +1,6 @@ /* * Zmanim Java API - * Copyright (C) 2004-2022 Eliyahu Hershfeld + * Copyright (C) 2004-2023 Eliyahu Hershfeld * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) @@ -23,7 +23,7 @@ * @todo Consider methods that would allow atmospheric modeling. This can currently be adjusted by {@link * #setRefraction(double) setting the refraction}. * - * @author © Eliyahu Hershfeld 2004 - 2022 + * @author © Eliyahu Hershfeld 2004 - 2023 */ public abstract class AstronomicalCalculator implements Cloneable { /** @@ -146,6 +146,22 @@ public abstract double getUTCSunrise(Calendar calendar, GeoLocation geoLocation, */ public abstract double getUTCSunset(Calendar calendar, GeoLocation geoLocation, double zenith, boolean adjustForElevation); + + + /** + * Return solar noon (UTC) for the given day at the + * given location on earth. The the {@link com.kosherjava.zmanim.util.NOAACalculator} implementation calculates + * true solar noon, while the {@link com.kosherjava.zmanim.util.SunTimesCalculator} approximates it, calculating + * the time as halfway between sunrise and sunset. + * + * @param calendar + * Used to calculate day of year. + * @param geoLocation + * The location information used for astronomical calculating sun times. + * + * @return the time in minutes from zero UTC + */ + public abstract double getUTCNoon(Calendar calendar, GeoLocation geoLocation); /** * Method to return the adjustment to the zenith required to account for the elevation. Since a person at a higher diff --git a/src/main/java/com/kosherjava/zmanim/util/NOAACalculator.java b/src/main/java/com/kosherjava/zmanim/util/NOAACalculator.java index ef47cc78..3785ec62 100644 --- a/src/main/java/com/kosherjava/zmanim/util/NOAACalculator.java +++ b/src/main/java/com/kosherjava/zmanim/util/NOAACalculator.java @@ -1,17 +1,17 @@ /* * Zmanim Java API - * Copyright (C) 2004-2018 Eliyahu Hershfeld + * Copyright (C) 2004-2023 Eliyahu Hershfeld * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, - * or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, + * or connect to: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html */ package com.kosherjava.zmanim.util; @@ -19,25 +19,26 @@ /** * Implementation of sunrise and sunset methods to calculate astronomical times based on the NOAA algorithm. This calculator uses the Java algorithm based on the implementation by NOAA - National Oceanic and Atmospheric Administration's Surface Radiation Research Branch. NOAA's implementation is based on equations from Astronomical Algorithms by Jean Meeus. Added to the algorithm is an adjustment of the zenith + * href="https://noaa.gov">NOAA algorithm. This calculator uses the Java algorithm based on the implementation by NOAA - National Oceanic and Atmospheric Administration's Surface Radiation Research Branch. NOAA's implementation is based on equations from Astronomical Algorithms by Jean Meeus. Added to the algorithm is an adjustment of the zenith * to account for elevation. The algorithm can be found in the Wikipedia Sunrise Equation article. + * href="https://en.wikipedia.org/wiki/Sunrise_equation">Wikipedia Sunrise Equation article. * - * @author © Eliyahu Hershfeld 2011 - 2020 + * @author © Eliyahu Hershfeld 2011 - 2023 */ public class NOAACalculator extends AstronomicalCalculator { /** - * The Julian day of January 1, 2000 + * The Julian day of January 1, 2000, known as + * J2000.0. */ private static final double JULIAN_DAY_JAN_1_2000 = 2451545.0; /** - * Julian days per century + * Julian days per century. */ private static final double JULIAN_DAYS_PER_CENTURY = 36525.0; @@ -91,7 +92,7 @@ public double getUTCSunset(Calendar calendar, GeoLocation geoLocation, double ze } /** - * Return the Julian day from a Java Calendar + * Return the Julian day from a Java Calendar * * @param calendar * The Java Calendar @@ -113,7 +114,8 @@ private static double getJulianDay(Calendar calendar) { } /** - * Convert Julian day to centuries since J2000.0. + * Convert Julian day to centuries since J2000.0. * * @param julianDay * the Julian Day to convert @@ -124,10 +126,12 @@ private static double getJulianCenturiesFromJulianDay(double julianDay) { } /** - * Convert centuries since J2000.0 to Julian day. + * Convert centuries since J2000.0 to + * Julian day. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return the Julian Day corresponding to the Julian centuries passed in */ private static double getJulianDayFromJulianCenturies(double julianCenturies) { @@ -135,10 +139,11 @@ private static double getJulianDayFromJulianCenturies(double julianCenturies) { } /** - * Returns the Geometric Mean Longitude of the Sun. + * Returns the Geometric Mean Longitude of the Sun. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return the Geometric Mean Longitude of the Sun in degrees */ private static double getSunGeometricMeanLongitude(double julianCenturies) { @@ -154,10 +159,11 @@ private static double getSunGeometricMeanLongitude(double julianCenturies) { } /** - * Returns the Geometric Mean Anomaly of the Sun. + * Returns the Geometric Mean Anomaly of the Sun. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return the Geometric Mean Anomaly of the Sun in degrees */ private static double getSunGeometricMeanAnomaly(double julianCenturies) { @@ -165,10 +171,11 @@ private static double getSunGeometricMeanAnomaly(double julianCenturies) { } /** - * Return the eccentricity of earth's orbit. + * Return the eccentricity of earth's orbit. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return the unitless eccentricity */ private static double getEarthOrbitEccentricity(double julianCenturies) { @@ -176,10 +183,11 @@ private static double getEarthOrbitEccentricity(double julianCenturies) { } /** - * Returns the equation of center for the sun. + * Returns the equation of center for the sun. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return the equation of center for the sun in degrees */ private static double getSunEquationOfCenter(double julianCenturies) { @@ -195,10 +203,11 @@ private static double getSunEquationOfCenter(double julianCenturies) { } /** - * Return the true longitude of the sun + * Return the true longitude of the sun. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return the sun's true longitude in degrees */ private static double getSunTrueLongitude(double julianCenturies) { @@ -209,7 +218,7 @@ private static double getSunTrueLongitude(double julianCenturies) { } // /** - // * Returns the true anamoly of the sun. + // * Returns the true anamoly of the sun. // * // * @param julianCenturies // * the number of Julian centuries since J2000.0 @@ -223,10 +232,11 @@ private static double getSunTrueLongitude(double julianCenturies) { // } /** - * Return the apparent longitude of the sun + * Return the apparent longitude of the sun. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return sun's apparent longitude in degrees */ private static double getSunApparentLongitude(double julianCenturies) { @@ -238,10 +248,11 @@ private static double getSunApparentLongitude(double julianCenturies) { } /** - * Returns the mean obliquity of the ecliptic (Axial tilt). + * Returns the mean obliquity of the ecliptic (Axial tilt). * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return the mean obliquity in degrees */ private static double getMeanObliquityOfEcliptic(double julianCenturies) { @@ -251,11 +262,12 @@ private static double getMeanObliquityOfEcliptic(double julianCenturies) { } /** - * Returns the corrected obliquity of the ecliptic (Axial + * Returns the corrected obliquity of the ecliptic (Axial * tilt). * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return the corrected obliquity in degrees */ private static double getObliquityCorrection(double julianCenturies) { @@ -266,10 +278,11 @@ private static double getObliquityCorrection(double julianCenturies) { } /** - * Return the declination of the sun. + * Return the declination of the sun. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return * the sun's declination in degrees */ @@ -283,11 +296,12 @@ private static double getSunDeclination(double julianCenturies) { } /** - * Return the Equation of Time - the difference between + * Return the Equation of Time - the difference between * true solar time and mean solar time * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @return equation of time in minutes of time */ private static double getEquationOfTime(double julianCenturies) { @@ -311,16 +325,16 @@ private static double getEquationOfTime(double julianCenturies) { } /** - * Return the hour angle of the sun at sunrise for the - * latitude. + * Return the hour angle of the sun in + * radians at sunrise for the latitude. * * @param lat - * , the latitude of observer in degrees + * the latitude of observer in degrees * @param solarDec * the declination angle of sun in degrees * @param zenith * the zenith - * @return hour angle of sunrise in radians + * @return hour angle of sunrise in radians */ private static double getSunHourAngleAtSunrise(double lat, double solarDec, double zenith) { double latRad = Math.toRadians(lat); @@ -331,8 +345,9 @@ private static double getSunHourAngleAtSunrise(double lat, double solarDec, doub } /** - * Returns the hour angle of the sun at sunset for the - * latitude. TODO: use - {@link #getSunHourAngleAtSunrise(double, double, double)} implementation to avoid + * Returns the hour angle of the sun in radiansat sunset for the latitude. + * @todo use - {@link #getSunHourAngleAtSunrise(double, double, double)} implementation to avoid * duplication of code. * * @param lat @@ -341,7 +356,7 @@ private static double getSunHourAngleAtSunrise(double lat, double solarDec, doub * the declination angle of sun in degrees * @param zenith * the zenith - * @return the hour angle of sunset in radians + * @return the hour angle of sunset in radians */ private static double getSunHourAngleAtSunset(double lat, double solarDec, double zenith) { double latRad = Math.toRadians(lat); @@ -353,7 +368,7 @@ private static double getSunHourAngleAtSunset(double lat, double solarDec, doubl } /** - * Return the Solar Elevation for the + * Return the Solar Elevation for the * horizontal coordinate system at the given location at the given time. Can be negative if the sun is below the * horizon. Not corrected for altitude. * @@ -386,7 +401,7 @@ public static double getSolarElevation(Calendar cal, double lat, double lon) { } /** - * Return the Solar Azimuth for the + * Return the Solar Azimuth for the * horizontal coordinate system at the given location at the given time. Not corrected for altitude. True south is 0 * degrees. * @@ -396,7 +411,7 @@ public static double getSolarElevation(Calendar cal, double lat, double lon) { * latitude of location for calculation * @param lon * longitude of location for calculation - * @return FIXME + * @return the solar azimuth */ public static double getSolarAzimuth(Calendar cal, double lat, double lon) { @@ -420,8 +435,8 @@ public static double getSolarAzimuth(Calendar cal, double lat, double lon) { } /** - * Return the Universal Coordinated Time (UTC) - * of sunrise for the given day at the given location on earth + * Return the Universal Coordinated Time (UTC) + * of sunrise for the given day at the given location on earth. * * @param julianDay * the Julian day @@ -464,20 +479,59 @@ private static double getSunriseUTC(double julianDay, double latitude, double lo timeUTC = 720 + timeDiff - eqTime; // in minutes return timeUTC; } + + /** + * Return the Universal Coordinated Time (UTC) + * of solar noon for the given day at the given location + * on earth. This implementation returns true solar noon as opposed to the time halfway between sunrise and sunset. + * Other calculators may return a more simplified calculation of halfway between sunrise and sunset. See The Definition of Chatzos for details on + * solar noon calculations. + * @see com.kosherjava.zmanim.util.AstronomicalCalculator#getUTCNoon(Calendar, GeoLocation) + * @see #getSolarNoonUTC(double, double) + * + * @param calendar + * The Calendar representing the date to calculate solar noon for + * @param geoLocation + * The location information used for astronomical calculating sun times. This class uses only requires + * the longitude for calculating noon since it is the same time anywhere along the longitude line. + * @return the time in minutes from zero UTC + */ + public double getUTCNoon(Calendar calendar, GeoLocation geoLocation) { + double julianDay = getJulianDay(calendar); + double julianCenturies = getJulianCenturiesFromJulianDay(julianDay); + + double noon = getSolarNoonUTC(julianCenturies, -geoLocation.getLongitude()); + noon = noon / 60; + + // ensure that the time is >= 0 and < 24 + while (noon < 0.0) { + noon += 24.0; + } + while (noon >= 24.0) { + noon -= 24.0; + } + return noon; + } /** - * Return the Universal Coordinated Time (UTC) - * of solar noon for the given day at the given location + * Return the Universal Coordinated Time (UTC) + * of of solar noon for the given day at the given location * on earth. * * @param julianCenturies - * the number of Julian centuries since J2000.0 + * the number of Julian centuries since J2000.0. * @param longitude * the longitude of observer in degrees + * * @return the time in minutes from zero UTC + * + * @see com.kosherjava.zmanim.util.AstronomicalCalculator#getUTCNoon(Calendar, GeoLocation) + * @see #getUTCNoon(Calendar, GeoLocation) */ private static double getSolarNoonUTC(double julianCenturies, double longitude) { - // First pass uses approximate solar noon to calculate eqtime + // First pass uses approximate solar noon to calculate equation of time double tnoon = getJulianCenturiesFromJulianDay(getJulianDayFromJulianCenturies(julianCenturies) + longitude / 360.0); double eqTime = getEquationOfTime(tnoon); @@ -491,8 +545,8 @@ private static double getSolarNoonUTC(double julianCenturies, double longitude) } /** - * Return the Universal Coordinated Time (UTC) - * of sunset for the given day at the given location on earth + * Return the Universal Coordinated Time (UTC) + * of sunset for the given day at the given location on earth. * * @param julianDay * the Julian day diff --git a/src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java b/src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java index 4007eaca..fda0cc17 100644 --- a/src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java @@ -1,6 +1,6 @@ /* * Zmanim Java API - * Copyright (C) 2004-2018 Eliyahu Hershfeld + * Copyright (C) 2004-2023 Eliyahu Hershfeld * * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) @@ -11,7 +11,7 @@ * details. * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA, - * or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html + * or connect to: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html */ package com.kosherjava.zmanim.util; @@ -19,14 +19,14 @@ /** * Implementation of sunrise and sunset methods to calculate astronomical times. This calculator uses the Java algorithm - * written by Kevin - * Boone that is based on the US Naval Observatory'sAlmanac for Computer algorithm ( Amazon, Barnes & Noble) and is - * used with his permission. Added to Kevin's code is adjustment of the zenith to account for elevation. + * written by Kevin + * Boone that is based on the US Naval Observatory'sAstronomical Almanac and used with his permission. Added to Kevin's + * code is adjustment of the zenith to account for elevation. This algorithm returns the same time every year and does not + * account for leap years. It is not as accurate as the Jean Meeus based {@link NOAACalculator} that is the default calculator + * use by the KosherJava zmanim library. * - * @author © Eliyahu Hershfeld 2004 - 2020 + * @author © Eliyahu Hershfeld 2004 - 2023 * @author © Kevin Boone 2000 */ public class SunTimesCalculator extends AstronomicalCalculator { @@ -252,4 +252,26 @@ private static double getTimeUTC(Calendar calendar, GeoLocation geoLocation, dou } return pocessedTime; } + + /** + * Return the Universal Coordinated Time (UTC) + * of solar noon for the given day at the given location + * on earth. This implementation returns solar noon as the time halfway between sunrise and sunset. + * Other calculators may return true solar noon. See The Definition of Chatzos for details on solar + * noon calculations. + * @see com.kosherjava.zmanim.util.AstronomicalCalculator#getUTCNoon(Calendar, GeoLocation) + * @see NOAACalculator + * + * @param calendar + * The Calendar representing the date to calculate solar noon for + * @param geoLocation + * The location information used for astronomical calculating sun times. + * @return the time in minutes from zero UTC + */ + public double getUTCNoon(Calendar calendar, GeoLocation geoLocation) { + double sunrise = getUTCSunrise(calendar, geoLocation, 90, true); + double sunset = getUTCSunset(calendar, geoLocation, 90, true); + return (sunrise + ((sunset - sunrise) / 2)); + } } diff --git a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/YomiCalculatorTest.java b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/YomiCalculatorTest.java index 79df128d..5b24bd7c 100644 --- a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/YomiCalculatorTest.java +++ b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/YomiCalculatorTest.java @@ -15,7 +15,7 @@ public void testCorrectDaf1() { Daf daf = YomiCalculator.getDafYomiBavli(jewishCalendar); Assert.assertEquals(5, daf.getMasechtaNumber()); Assert.assertEquals(2, daf.getDaf()); - System.out.println(hdf.formatDafYomiYerushalmi(jewishCalendar.getDafYomiBavli())); + System.out.println(hdf.formatDafYomiBavli(jewishCalendar.getDafYomiBavli())); } @Test @@ -24,7 +24,7 @@ public void testCorrectDaf2() { Daf daf = YomiCalculator.getDafYomiBavli(jewishCalendar); Assert.assertEquals(4, daf.getMasechtaNumber()); Assert.assertEquals(14, daf.getDaf()); - System.out.println(hdf.formatDafYomiYerushalmi(jewishCalendar.getDafYomiBavli())); + System.out.println(hdf.formatDafYomiBavli(jewishCalendar.getDafYomiBavli())); } @Test @@ -33,6 +33,6 @@ public void testCorrectDaf3() { Daf daf = YomiCalculator.getDafYomiBavli(jewishCalendar); Assert.assertEquals(23, daf.getMasechtaNumber()); Assert.assertEquals(47, daf.getDaf()); - System.out.println(hdf.formatDafYomiYerushalmi(jewishCalendar.getDafYomiBavli())); + System.out.println(hdf.formatDafYomiBavli(jewishCalendar.getDafYomiBavli())); } }