11/*
22 * Zmanim Java API
3- * Copyright (C) 2004-2024 Eliyahu Hershfeld
3+ * Copyright (C) 2004-2025 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)
5555 * // will sort shaah 1.6, shaah GRA, sunrise, sunset
5656 * </pre>
5757 *
58- * @author © Eliyahu Hershfeld 2007-2024
58+ * @author © Eliyahu Hershfeld 2007-2025
5959 * @todo Add secondary sorting. As of now the {@code Comparator}s in this class do not sort by secondary order. This means that when sorting a
6060 * {@link java.util.Collection} of <em>zmanim</em> and using the {@link #DATE_ORDER} {@code Comparator} will have the duration based <em>zmanim</em>
6161 * at the end, but they will not be sorted by duration. This should be N/A for label based sorting.
@@ -82,16 +82,34 @@ public class Zman {
8282 * A longer description or explanation of a <em>zman</em>.
8383 */
8484 private String description ;
85+
86+ /**
87+ * The location information of the <em>zman</em>.
88+ */
89+ private GeoLocation geoLocation ;
8590
8691 /**
87- * The constructor setting a {@link Date} based <em>zman</em> and a label.
92+ * The constructor setting a {@link Date} based <em>zman</em> and a label. In most cases you will likely want to call
93+ * {@link #Zman(Date, GeoLocation, String)} that also sets the location.
8894 * @param date the Date of the <em>zman</em>.
8995 * @param label the label of the <em>zman</em> such as "<em>Sof Zman Krias Shema GRA</em>".
90- * @see #Zman(long , String)
96+ * @see #Zman(Date, GeoLocation , String)
9197 */
9298 public Zman (Date date , String label ) {
93- this .label = label ;
99+ this (date , null , label );
100+ }
101+
102+ /**
103+ * The constructor setting a {@link Date} based <em>zman</em> and a label. In most cases you will likely want to call
104+ * {@link #Zman(Date, GeoLocation, String)} that also sets the geo location.
105+ * @param date the Date of the <em>zman</em>.
106+ * @param geoLocation the {@link GeoLocation} of the <em>zman</em>.
107+ * @param label the label of the <em>zman</em> such as "<em>Sof Zman Krias Shema GRA</em>".
108+ */
109+ public Zman (Date date , GeoLocation geoLocation , String label ) {
94110 this .zman = date ;
111+ this .geoLocation = geoLocation ;
112+ this .label = label ;
95113 }
96114
97115 /**
@@ -125,6 +143,22 @@ public Date getZman() {
125143 public void setZman (Date date ) {
126144 this .zman = date ;
127145 }
146+
147+ /**
148+ * Returns the {link TimeZone} of the <em>zman</em>.
149+ * @return the time zone
150+ */
151+ public GeoLocation getGeoLocation () {
152+ return geoLocation ;
153+ }
154+
155+ /**
156+ * Sets the {@code GeoLocation} of the <em>zman</em>.
157+ * @param geoLocation the {@code GeoLocation} of the <em>zman</em>.
158+ */
159+ public void setGeoLocation (GeoLocation geoLocation ) {
160+ this .geoLocation = geoLocation ;
161+ }
128162
129163 /**
130164 * Returns a duration based <em>zman</em> such as {@link com.kosherjava.zmanim.AstronomicalCalendar#getTemporalHour() temporal hour}
@@ -241,6 +275,12 @@ public int compare(Zman zman1, Zman zman2) {
241275 * <Zman>
242276 * <Label>Sof Zman Krias Shema GRA</Label>
243277 * <Zman>1969-02-08T09:37:56.820</Zman>
278+ * <TimeZone>
279+ * <TimezoneName>America/Montreal</TimezoneName>
280+ * <TimeZoneDisplayName>Eastern Standard Time</TimeZoneDisplayName>
281+ * <TimezoneGMTOffset>-5</TimezoneGMTOffset>
282+ * <TimezoneDSTOffset>1</TimezoneDSTOffset>
283+ * </TimeZone>
244284 * <Duration>0</Duration>
245285 * <Description>Sof Zman Krias Shema GRA is 3 sha'os zmaniyos calculated from sunrise to sunset.</Description>
246286 * </Zman>
@@ -253,6 +293,7 @@ public String toXML() {
253293 sb .append ("<Zman>\n " );
254294 sb .append ("\t <Label>" ).append (getLabel ()).append ("</Label>\n " );
255295 sb .append ("\t <Zman>" ).append (getZman () == null ? "" : formatter .format (getZman ())).append ("</Zman>\n " );
296+ sb .append ("\t " + getGeoLocation ().toXML ().replaceAll ("\n " , "\n \t " ));
256297 sb .append ("\n \t <Duration>" ).append (getDuration ()).append ("</Duration>\n " );
257298 sb .append ("\t <Description>" ).append (getDescription ()).append ("</Description>\n " );
258299 sb .append ("</Zman>" );
@@ -264,10 +305,11 @@ public String toXML() {
264305 */
265306 public String toString () {
266307 StringBuilder sb = new StringBuilder ();
267- sb .append ("\n Label:\t \t \t " ).append (this .getLabel ());
268- sb .append ("\n Zman:\t \t \t " ).append (getZman ());
269- sb .append ("\n Duration:\t \t \t " ).append (getDuration ());
270- sb .append ("\n Description:\t \t \t " ).append (getDescription ());
308+ sb .append ("\n Label:\t " ).append (this .getLabel ());
309+ sb .append ("\n Zman:\t " ).append (getZman ());
310+ sb .append ("\n GeoLocation:\t " ).append (getGeoLocation ().toString ().replaceAll ("\n " , "\n \t " ));
311+ sb .append ("\n Duration:\t " ).append (getDuration ());
312+ sb .append ("\n Description:\t " ).append (getDescription ());
271313 return sb .toString ();
272314 }
273315}
0 commit comments