Skip to content

Commit fdf6c55

Browse files
authored
Use calculator's getUTCNoon in getSunTransit
This is as opposed to the previous behavior of returning getSunTransit(getSeaLevelSunrise(), getSeaLevelSunset()) that would be halfway between sunrise and sunset. If the NOOACalculator is used, it will now return proper astronomical noon, while the SunTimesCalculator that uses the UNO algorithm will continue using the time halfway between sunrise and sunset. See [The Definition of Chatzos](https://kosherjava.com/2020/07/02/definition-of-chatzos/) for additional information. The ZmanimCalendar will have this as an option, defaulting to halfway between sunrise and sunset. Also cleaned up some links.
1 parent 2cd5be0 commit fdf6c55

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Zmanim Java API
3-
* Copyright (C) 2004-2022 Eliyahu Hershfeld
3+
* Copyright (C) 2004-2023 Eliyahu Hershfeld
44
*
55
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
66
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
@@ -10,7 +10,7 @@
1010
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
1111
* details.
1212
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
13-
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA,
13+
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA,
1414
* or connect to: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
1515
*/
1616
package com.kosherjava.zmanim;
@@ -64,7 +64,7 @@
6464
* </pre>
6565
*
6666
*
67-
* @author &copy; Eliyahu Hershfeld 2004 - 2022
67+
* @author &copy; Eliyahu Hershfeld 2004 - 2023
6868
*/
6969
public class AstronomicalCalendar implements Cloneable {
7070

@@ -489,11 +489,17 @@ public long getTemporalHour(Date startOfday, Date endOfDay) {
489489
}
490490

491491
/**
492-
* A method that returns sundial or solar noon. It occurs when the Sun is <a href
493-
* ="https://en.wikipedia.org/wiki/Transit_%28astronomy%29">transiting</a> the <a
494-
* href="https://en.wikipedia.org/wiki/Meridian_%28astronomy%29">celestial meridian</a>. In this class it is
495-
* calculated as halfway between sea level sunrise and sea level sunset, which can be slightly off the real transit
496-
* time due to changes in declination (the lengthening or shortening day).
492+
* A method that returns sundial or solar noon. It occurs when the Sun is <a href=
493+
* "https://en.wikipedia.org/wiki/Transit_%28astronomy%29">transiting</a> the <a
494+
* href="https://en.wikipedia.org/wiki/Meridian_%28astronomy%29">celestial meridian</a>. The calculations used by
495+
* this class depend on the {@link AstronomicalCalculator} used. If this calendar instance is {@link
496+
* #setAstronomicalCalculator(AstronomicalCalculator) set} to use the {@link com.kosherjava.zmanim.util.NOAACalculator}
497+
* (the default) it will calculate astronomical noon. If the calendar instance is to use the
498+
* {@link com.kosherjava.zmanim.util.SunTimesCalculator}, that does not have code to calculate astronomical noon, the
499+
* sun transit is calculated as halfway between sea level sunrise and sea level sunset, which can be slightly off the
500+
* real transit time due to changes in declination (the lengthening or shortening day). See <a href=
501+
* "https://kosherjava.com/2020/07/02/definition-of-chatzos/">The Definition of Chatzos</a> for details on the proper
502+
* definition of solar noon / midday.
497503
*
498504
* @return the <code>Date</code> representing Sun's transit. If the calculation can't be computed such as in the
499505
* 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) {
502508
* @see #getTemporalHour()
503509
*/
504510
public Date getSunTransit() {
505-
return getSunTransit(getSeaLevelSunrise(), getSeaLevelSunset());
511+
double noon = getAstronomicalCalculator().getUTCNoon(getAdjustedCalendar(), getGeoLocation());
512+
return getDateFromTime(noon, false);
506513
}
507514

508515
/**
@@ -730,10 +737,10 @@ public AstronomicalCalculator getAstronomicalCalculator() {
730737
/**
731738
* A method to set the {@link AstronomicalCalculator} used for astronomical calculations. The Zmanim package ships
732739
* with a number of different implementations of the <code>abstract</code> {@link AstronomicalCalculator} based on
733-
* different algorithms, including {@link com.kosherjava.zmanim.util.SunTimesCalculator one implementation} based
734-
* on the <a href = "http://aa.usno.navy.mil/">US Naval Observatory's</a> algorithm, and
735-
* {@link com.kosherjava.zmanim.util.NOAACalculator another} based on <a href="https://noaa.gov">NOAA's</a>
736-
* algorithm. This allows easy runtime switching and comparison of different algorithms.
740+
* different algorithms, including the default {@link com.kosherjava.zmanim.util.NOAACalculator} based on <a href=
741+
* "https://noaa.gov">NOAA's</a> implementation of Jean Meeus's algorithms as well as {@link
742+
* com.kosherjava.zmanim.util.SunTimesCalculator} based on the <a href = "https://www.cnmoc.usff.navy.mil/usno/">US
743+
* Naval Observatory's</a> algorithm,. This allows easy runtime switching and comparison of different algorithms.
737744
*
738745
* @param astronomicalCalculator
739746
* The astronomicalCalculator to set.

0 commit comments

Comments
 (0)