Skip to content

Commit aa43a9b

Browse files
authored
Changes to support astronomical noon elsewhere
This adds getUTCNoon() to support adding it in the parent class. Thought this calculator does not natively support astronomical noon, adding the implementation here to return noon as halfway between sunrise and sunset, allows it to be added and enforced in the abstract AstronomicalCalculator parent class.
1 parent f2157e4 commit aa43a9b

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

src/main/java/com/kosherjava/zmanim/util/SunTimesCalculator.java

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Zmanim Java API
3-
* Copyright (C) 2004-2018 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)
@@ -11,22 +11,22 @@
1111
* details.
1212
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
1313
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA,
14-
* or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
14+
* or connect to: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
1515
*/
1616
package com.kosherjava.zmanim.util;
1717

1818
import java.util.Calendar;
1919

2020
/**
2121
* Implementation of sunrise and sunset methods to calculate astronomical times. This calculator uses the Java algorithm
22-
* written by <a href="http://web.archive.org/web/20090531215353/http://www.kevinboone.com/suntimes.html">Kevin
23-
* Boone</a> that is based on the <a href = "http://aa.usno.navy.mil/">US Naval Observatory's</a><a
24-
* href="http://aa.usno.navy.mil/publications/docs/asa.php">Almanac</a> for Computer algorithm ( <a
25-
* href="http://www.amazon.com/exec/obidos/tg/detail/-/0160515106/">Amazon</a>, <a
26-
* href="http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?isbn=0160515106">Barnes &amp; Noble</a>) and is
27-
* used with his permission. Added to Kevin's code is adjustment of the zenith to account for elevation.
22+
* written by <a href="htts://web.archive.org/web/20090531215353/http://www.kevinboone.com/suntimes.html">Kevin
23+
* Boone</a> that is based on the <a href = "https://aa.usno.navy.mil/">US Naval Observatory's</a><a
24+
* href="https://aa.usno.navy.mil/publications/asa">Astronomical Almanac</a> and used with his permission. Added to Kevin's
25+
* code is adjustment of the zenith to account for elevation. This algorithm returns the same time every year and does not
26+
* account for leap years. It is not as accurate as the Jean Meeus based {@link NOAACalculator} that is the default calculator
27+
* use by the KosherJava <em>zmanim</em> library.
2828
*
29-
* @author &copy; Eliyahu Hershfeld 2004 - 2020
29+
* @author &copy; Eliyahu Hershfeld 2004 - 2023
3030
* @author &copy; Kevin Boone 2000
3131
*/
3232
public class SunTimesCalculator extends AstronomicalCalculator {
@@ -252,4 +252,26 @@ private static double getTimeUTC(Calendar calendar, GeoLocation geoLocation, dou
252252
}
253253
return pocessedTime;
254254
}
255+
256+
/**
257+
* Return the <a href="https://en.wikipedia.org/wiki/Universal_Coordinated_Time">Universal Coordinated Time</a> (UTC)
258+
* of <a href="https://en.wikipedia.org/wiki/Noon#Solar_noon">solar noon</a> for the given day at the given location
259+
* on earth. This implementation returns solar noon as the time halfway between sunrise and sunset.
260+
* Other calculators may return true solar noon. See <a href=
261+
* "https://kosherjava.com/2020/07/02/definition-of-chatzos/">The Definition of Chatzos</a> for details on solar
262+
* noon calculations.
263+
* @see com.kosherjava.zmanim.util.AstronomicalCalculator#getUTCNoon(Calendar, GeoLocation)
264+
* @see NOAACalculator
265+
*
266+
* @param calendar
267+
* The Calendar representing the date to calculate solar noon for
268+
* @param geoLocation
269+
* The location information used for astronomical calculating sun times.
270+
* @return the time in minutes from zero UTC
271+
*/
272+
public double getUTCNoon(Calendar calendar, GeoLocation geoLocation) {
273+
double sunrise = getUTCSunrise(calendar, geoLocation, 90, true);
274+
double sunset = getUTCSunset(calendar, geoLocation, 90, true);
275+
return (sunrise + ((sunset - sunrise) / 2));
276+
}
255277
}

0 commit comments

Comments
 (0)