001/*
002 * Zmanim Java API
003 * Copyright (C) 2019 - 2022 Eliyahu Hershfeld
004 * Copyright (C) 2019 - 2021 Y Paritcher
005 *
006 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
007 * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
008 * any later version.
009 *
010 * This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied
011 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
012 * details.
013 * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
014 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA,
015 * or connect to: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
016 */
017package com.kosherjava.zmanim.hebrewcalendar;
018
019import java.util.Calendar;
020
021/**
022 * Tefila Rules is a utility class that covers the various <em>halachos</em> and <em>minhagim</em> regarding
023 * changes to daily <em>tefila</em> / prayers, based on the Jewish calendar. This is mostly useful for use in
024 * developing <em>siddur</em> type applications, but it is also valuable for <em>shul</em> calendars that set
025 * <em>tefila</em> times based on if <a href="https://en.wikipedia.org/wiki/Tachanun"><em>tachanun</em></a> is
026 * recited that day. There are many settings in this class to cover the vast majority of <em>minhagim</em>, but
027 * there are likely some not covered here. The source for many of the <em>chasidishe minhagim</em> can be found
028 * in the <a href="https://www.nli.org.il/he/books/NNL_ALEPH001141272/NLI">Minhag Yisrael Torah</a> on Orach
029 * Chaim 131.
030 * Dates used in specific communities such as specific <em>yahrzeits</em> or a holidays like Purim Mezhbizh
031 * (Medzhybizh) celebrated on 11 {@link JewishDate#TEVES <em>Teves</em>} or <a href=
032 * "https://en.wikipedia.org/wiki/Second_Purim#Purim_Saragossa_(18_Shevat)">Purim Saragossa</a> celebrated on
033 * the (17th or) 18th of {@link JewishDate#SHEVAT <em>Shevat</em>} are not (and likely will not be) supported by
034 * this class.
035 * <p>Sample code:
036 * <pre style="background: #FEF0C9; display: inline-block;">
037 * TefilaRules tr = new TefilaRules();
038 * JewishCalendar jewishCalendar = new JewishCalendar();
039 * HebrewDateFormatter hdf = new HebrewDateFormatter();
040 * jewishCalendar.setJewishDate(5783, JewishDate.TISHREI, 1); // Rosh Hashana
041 * System.out.println(hdf.format(jewishCalendar) + ": " + tr.isTachanunRecitedShacharis(jd));
042 * jewishCalendar.setJewishDate(5783, JewishDate.ADAR, 17);
043 * System.out.println(hdf.format(jewishCalendar) + ": " + tr.isTachanunRecitedShacharis(jewishCalendar));
044 * tr.setTachanunRecitedWeekOfPurim(false);
045 * System.out.println(hdf.format(jewishCalendar) + ": " + tr.isTachanunRecitedShacharis(jewishCalendar));</pre>
046 * 
047 * @author &copy; Y. Paritcher 2019 - 2021
048 * @author &copy; Eliyahu Hershfeld 2019 - 2022
049 * 
050 * @todo The following items may be added at a future date.
051 * <ol>
052 * <li><em>Lamnatzaiach</em></li>
053 * <li><em>Mizmor Lesoda</em></li>
054 * <li><em>Behab</em></li>
055 * <li><em>Selichos</em></li>
056 * <li>...</li>
057 * </ol>
058 */
059public class TefilaRules {
060        /**
061         * The default value is <code>true</code>.
062         * @see #isTachanunRecitedEndOfTishrei()
063         * @see #setTachanunRecitedEndOfTishrei(boolean)
064         */
065        private boolean tachanunRecitedEndOfTishrei = true;
066        
067        /**
068         * The default value is <code>false</code>.
069         * @see #isTachanunRecitedWeekAfterShavuos()
070         * @see #setTachanunRecitedWeekAfterShavuos(boolean)
071         */
072        private boolean tachanunRecitedWeekAfterShavuos = false;
073        
074        /**
075         * The default value is <code>true</code>.
076         * @see #isTachanunRecited13SivanOutOfIsrael()
077         * @see #setTachanunRecited13SivanOutOfIsrael(boolean)
078         */
079        private boolean tachanunRecited13SivanOutOfIsrael = true;
080        
081        /**
082         * The default value is <code>false</code>.
083         * @see #isTachanunRecitedPesachSheni()
084         * @see #setTachanunRecitedPesachSheni(boolean)
085         */
086        private boolean tachanunRecitedPesachSheni = false;
087        
088        /**
089         * The default value is <code>true</code>.
090         * @see #isTachanunRecited15IyarOutOfIsrael()
091         * @see #setTachanunRecited15IyarOutOfIsrael(boolean)
092         */
093        private boolean tachanunRecited15IyarOutOfIsrael = true;
094        
095        /**
096         * The default value is <code>false</code>.
097         * @see #isTachanunRecitedMinchaErevLagBaomer()
098         * @see #setTachanunRecitedMinchaErevLagBaomer(boolean)
099         */
100        private boolean tachanunRecitedMinchaErevLagBaomer = false;
101        
102        /**
103         * The default value is <code>true</code>.
104         * @see #isTachanunRecitedShivasYemeiHamiluim()
105         * @see #setTachanunRecitedShivasYemeiHamiluim(boolean)
106         */
107        private boolean tachanunRecitedShivasYemeiHamiluim = true;
108        
109        /**
110         * The default value is <code>true</code>.
111         * @see #isTachanunRecitedWeekOfHod()
112         * @see #setTachanunRecitedWeekOfHod(boolean)
113         */
114        private boolean tachanunRecitedWeekOfHod = true;
115        
116        /**
117         * The default value is <code>true</code>.
118         * @see #isTachanunRecitedWeekOfPurim()
119         * @see #setTachanunRecitedWeekOfPurim(boolean)
120         */
121        private boolean tachanunRecitedWeekOfPurim = true;
122        
123        /**
124         * The default value is <code>true</code>.
125         * @see #isTachanunRecitedFridays()
126         * @see #setTachanunRecitedFridays(boolean)
127         */
128        private boolean tachanunRecitedFridays = true;
129        
130        /**
131         * The default value is <code>true</code>.
132         * @see #isTachanunRecitedSundays()
133         * @see #setTachanunRecitedSundays(boolean)
134         */
135        private boolean tachanunRecitedSundays = true;
136        
137        /**
138         * The default value is <code>true</code>.
139         * @see #isTachanunRecitedMinchaAllYear()
140         * @see #setTachanunRecitedMinchaAllYear(boolean)
141         */
142        private boolean tachanunRecitedMinchaAllYear = true;    
143        
144        /**
145         * Returns if <em>tachanun</em> is recited during <em>shacharis</em> on the day in question. See the many
146         * <em>minhag</em> based settings that are available in this class.
147         * 
148         * @param jewishCalendar the Jewish calendar day.
149         * @return if <em>tachanun</em> is recited during <em>shacharis</em>.
150         * @see #isTachanunRecitedMincha(JewishCalendar)
151         */
152        public boolean isTachanunRecitedShacharis(JewishCalendar jewishCalendar) {
153                int holidayIndex = jewishCalendar.getYomTovIndex();
154                int day = jewishCalendar.getJewishDayOfMonth();
155                int month = jewishCalendar.getJewishMonth();
156
157                if (jewishCalendar.getDayOfWeek() == Calendar.SATURDAY
158                                || (!tachanunRecitedSundays && jewishCalendar.getDayOfWeek() == Calendar.SUNDAY)
159                                || (!tachanunRecitedFridays && jewishCalendar.getDayOfWeek() == Calendar.FRIDAY)
160                                || month == JewishDate.NISSAN
161                                || (month == JewishDate.TISHREI && ((!tachanunRecitedEndOfTishrei && day > 8)
162                                || (tachanunRecitedEndOfTishrei && (day > 8 && day < 22))))
163                                || (month == JewishDate.SIVAN && (tachanunRecitedWeekAfterShavuos && day < 7
164                                                || !tachanunRecitedWeekAfterShavuos && day < (!jewishCalendar.getInIsrael()
165                                                                && !tachanunRecited13SivanOutOfIsrael ? 14: 13)))
166                                || (jewishCalendar.isYomTov() && (! jewishCalendar.isTaanis()
167                                                || (!tachanunRecitedPesachSheni && holidayIndex == JewishCalendar.PESACH_SHENI))) // Erev YT is included in isYomTov()
168                                || (!jewishCalendar.getInIsrael() && !tachanunRecitedPesachSheni && !tachanunRecited15IyarOutOfIsrael
169                                                && jewishCalendar.getJewishMonth() == JewishDate.IYAR && day == 15)
170                                || holidayIndex == JewishCalendar.TISHA_BEAV || jewishCalendar.isIsruChag()
171                                || jewishCalendar.isRoshChodesh()
172                                || (!tachanunRecitedShivasYemeiHamiluim &&
173                                                ((!jewishCalendar.isJewishLeapYear() && month == JewishDate.ADAR)
174                                                                || (jewishCalendar.isJewishLeapYear() && month == JewishDate.ADAR_II)) && day > 22)
175                                || (!tachanunRecitedWeekOfPurim &&
176                                                ((!jewishCalendar.isJewishLeapYear() && month == JewishDate.ADAR)
177                                                                || (jewishCalendar.isJewishLeapYear() && month == JewishDate.ADAR_II)) && day > 10 && day < 18)
178                                || (jewishCalendar.isUseModernHolidays()
179                                                && (holidayIndex == JewishCalendar.YOM_HAATZMAUT || holidayIndex == JewishCalendar.YOM_YERUSHALAYIM))
180                                || (!tachanunRecitedWeekOfHod && month == JewishDate.IYAR && day > 13 && day < 21)) {
181                        return false;
182                }
183                return true;
184        }
185
186        /**
187         * Returns if <em>tachanun</em> is recited during <em>mincha</em> on the day in question.
188         * 
189         * @param jewishCalendar the Jewish calendar day.
190         * @return if <em>tachanun</em> is recited during <em>mincha</em>.
191         * @see #isTachanunRecitedShacharis(JewishCalendar)
192         */
193        public boolean isTachanunRecitedMincha(JewishCalendar jewishCalendar) {
194                JewishCalendar tomorrow = new JewishCalendar();
195                tomorrow = (JewishCalendar) jewishCalendar.clone();
196                tomorrow.forward(Calendar.DATE, 1);
197                
198                if (!tachanunRecitedMinchaAllYear
199                                        || jewishCalendar.getDayOfWeek() == Calendar.FRIDAY
200                                        || ! isTachanunRecitedShacharis(jewishCalendar) 
201                                        || (! isTachanunRecitedShacharis(tomorrow) && 
202                                                        !(tomorrow.getYomTovIndex() == JewishCalendar.EREV_ROSH_HASHANA) &&
203                                                        !(tomorrow.getYomTovIndex() == JewishCalendar.EREV_YOM_KIPPUR) &&
204                                                        !(tomorrow.getYomTovIndex() == JewishCalendar.PESACH_SHENI))
205                                        || ! tachanunRecitedMinchaErevLagBaomer && tomorrow.getYomTovIndex() == JewishCalendar.LAG_BAOMER) {
206                        return false;
207                }
208                return true;
209        }
210        
211        /**
212         * Returns if it is the Jewish day (starting the evening before) to start reciting <em>Vesein Tal Umatar Livracha</em>
213         * (<em>Sheailas Geshamim</em>). In Israel this is the 7th day of {@link JewishDate#CHESHVAN <em>Marcheshvan</em>}.
214         * Outside Israel recitation starts on the evening of December 4th (or 5th if it is the year before a civil leap year)
215         * in the 21st century and shifts a day forward every century not evenly divisible by 400. This method will return true
216         * if <em>vesein tal umatar</em> on the current Jewish date that starts on the previous night, so Dec 5/6 will be
217         * returned by this method in the 21st century. <em>vesein tal umatar</em> is not recited on <em>Shabbos</em> and the
218         * start date will be delayed a day when the start day is on a <em>Shabbos</em> (this can only occur out of Israel).
219         * 
220         * @param jewishCalendar the Jewish calendar day.
221         * 
222         * @return true if it is the first Jewish day (starting the prior evening of reciting <em>Vesein Tal Umatar Livracha</em>
223         *         (<em>Sheailas Geshamim</em>).
224         * 
225         * @see #isVeseinTalUmatarStartingTonight(JewishCalendar)
226         * @see #isVeseinTalUmatarRecited(JewishCalendar)
227         */
228        public boolean isVeseinTalUmatarStartDate(JewishCalendar jewishCalendar) {
229                if (jewishCalendar.getInIsrael()) {
230                         // The 7th Cheshvan can't occur on Shabbos, so always return true for 7 Cheshvan
231                        if (jewishCalendar.getJewishMonth() == JewishDate.CHESHVAN && jewishCalendar.getJewishDayOfMonth() == 7) {
232                                return true;
233                        }
234                } else {
235                        if (jewishCalendar.getDayOfWeek() == Calendar.SATURDAY) { //Not recited on Friday night
236                                return false;
237                        }
238                        if(jewishCalendar.getDayOfWeek() == Calendar.SUNDAY) { // When starting on Sunday, it can be the start date or delayed from Shabbos
239                                return jewishCalendar.getTekufasTishreiElapsedDays() == 48 || jewishCalendar.getTekufasTishreiElapsedDays() == 47;
240                        } else {
241                                return jewishCalendar.getTekufasTishreiElapsedDays() == 47;
242                        }
243                }
244                return false; // keep the compiler happy
245        }
246        
247        /**
248         * Returns if true if tonight is the first night to start reciting <em>Vesein Tal Umatar Livracha</em> (
249         * <em>Sheailas Geshamim</em>). In Israel this is the 7th day of {@link JewishDate#CHESHVAN
250         * <em>Marcheshvan</em>} (so the 6th will return true). Outside Israel recitation starts on the evening
251         * of December 4th (or 5th if it is the year before a civil leap year) in the 21st century and shifts a
252         * day forward every century not evenly divisible by 400. <em>Vesein tal umatar</em> is not recited on
253         * <em>Shabbos</em> and the start date will be delayed a day when the start day is on a <em>Shabbos</em>
254         * (this can only occur out of Israel).
255         * 
256         * @param jewishCalendar the Jewish calendar day.
257         * 
258         * @return true if it is the first Jewish day (starting the prior evening of reciting <em>Vesein Tal Umatar
259         *         Livracha</em> (<em>Sheailas Geshamim</em>).
260         * 
261         * @see #isVeseinTalUmatarStartDate(JewishCalendar)
262         * @see #isVeseinTalUmatarRecited(JewishCalendar)
263         */
264        public boolean isVeseinTalUmatarStartingTonight(JewishCalendar jewishCalendar) {
265                if (jewishCalendar.getInIsrael()) {
266                        // The 7th Cheshvan can't occur on Shabbos, so always return true for 6 Cheshvan
267                        if (jewishCalendar.getJewishMonth() == JewishDate.CHESHVAN && jewishCalendar.getJewishDayOfMonth() == 6) {
268                                        return true;
269                        }
270                } else {
271                        if (jewishCalendar.getDayOfWeek() == Calendar.FRIDAY) { //Not recited on Friday night
272                                return false;
273                        }
274                        if(jewishCalendar.getDayOfWeek() == Calendar.SATURDAY) { // When starting on motzai Shabbos, it can be the start date or delayed from Friday night
275                                return jewishCalendar.getTekufasTishreiElapsedDays() == 47 || jewishCalendar.getTekufasTishreiElapsedDays() == 46;
276                        } else {
277                                return jewishCalendar.getTekufasTishreiElapsedDays() == 46;
278                        }
279                }
280                return false;
281        }
282
283        /**
284         * Returns if <em>Vesein Tal Umatar Livracha</em> (<em>Sheailas Geshamim</em>) is recited. This will return
285         * true for the entire season, even on <em>Shabbos</em> when it is not recited.
286         * 
287         * @param jewishCalendar the Jewish calendar day.
288         * 
289         * @return true if <em>Vesein Tal Umatar Livracha</em> (<em>Sheailas Geshamim</em>) is recited.
290         * 
291         * @see #isVeseinTalUmatarStartDate(JewishCalendar)
292         * @see #isVeseinTalUmatarStartingTonight(JewishCalendar)
293         */
294        public boolean isVeseinTalUmatarRecited(JewishCalendar jewishCalendar) {
295                if (jewishCalendar.getJewishMonth() == JewishDate.NISSAN && jewishCalendar.getJewishDayOfMonth() < 15) {
296                        return true;
297                }
298                if (jewishCalendar.getJewishMonth() < JewishDate.CHESHVAN) {
299                        return false;
300                }
301                if (jewishCalendar.getInIsrael()) {
302                        return jewishCalendar.getJewishMonth() != JewishDate.CHESHVAN || jewishCalendar.getJewishDayOfMonth() >= 7;
303                } else {
304                        return jewishCalendar.getTekufasTishreiElapsedDays() >= 47;
305                }
306        }
307        
308        /**
309         * Returns if <em>Vesein Beracha</em> is recited. It is recited from 15 {@link JewishDate#NISSAN <em>Nissan</em>} to the
310         * point that {@link #isVeseinTalUmatarRecited(JewishCalendar) <em>vesein tal umatar</em> is recited}.
311         * 
312         * @param jewishCalendar the Jewish calendar day.
313         * @return true if <em>Vesein Beracha</em> is recited.
314         * @see #isVeseinTalUmatarRecited(JewishCalendar)
315         */
316        public boolean isVeseinBerachaRecited(JewishCalendar jewishCalendar) {
317                return ! isVeseinTalUmatarRecited(jewishCalendar);
318        }
319
320        /**
321         * Returns if the date is the start date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. The date is 22
322         * {@link JewishDate#TISHREI <em>Tishrei</em>}.
323         * 
324         * @param jewishCalendar the Jewish calendar day.
325         * @return true if the date is the start date for reciting <em>Mashiv Haruach Umorid Hageshem</em>.
326         * @see #isMashivHaruachEndDate(JewishCalendar)
327         * @see #isMashivHaruachRecited(JewishCalendar)
328         */
329        public boolean isMashivHaruachStartDate(JewishCalendar jewishCalendar) {
330                return jewishCalendar.getJewishMonth() == JewishDate.TISHREI && jewishCalendar.getJewishDayOfMonth() == 22;
331        }
332
333        /**
334         * Returns if the date is the end date for reciting <em>Mashiv Haruach Umorid Hageshem</em>. The date is 15
335         * {@link JewishDate#NISSAN <em>Nissan</em>}.
336         * 
337         * @param jewishCalendar the Jewish calendar day.
338         * @return true if the date is the end date for reciting <em>Mashiv Haruach Umorid Hageshem</em>.
339         * @see #isMashivHaruachStartDate(JewishCalendar)
340         * @see #isMashivHaruachRecited(JewishCalendar)
341         */
342        public boolean isMashivHaruachEndDate(JewishCalendar jewishCalendar) {
343                return jewishCalendar.getJewishMonth() == JewishDate.NISSAN && jewishCalendar.getJewishDayOfMonth() == 15;
344        }
345
346        /**
347         * Returns if <em>Mashiv Haruach Umorid Hageshem</em> is recited. This period starts on 22 {@link
348         * JewishDate#TISHREI <em>Tishrei</em>} and ends on the 15th day of {@link JewishDate#NISSAN <em>Nissan</em>}.
349         * 
350         * @param jewishCalendar the Jewish calendar day.
351         * @return true if <em>Mashiv Haruach Umorid Hageshem</em> is recited.
352         * @see #isMashivHaruachStartDate(JewishCalendar)
353         * @see #isMashivHaruachEndDate(JewishCalendar)
354         */
355        public boolean isMashivHaruachRecited(JewishCalendar jewishCalendar) {
356                JewishDate startDate = new JewishDate(jewishCalendar.getJewishYear(), JewishDate.TISHREI, 22);
357                JewishDate endDate = new JewishDate(jewishCalendar.getJewishYear(), JewishDate.NISSAN, 15);
358                return jewishCalendar.compareTo(startDate) > 0 && jewishCalendar.compareTo(endDate) < 0;
359        }
360
361        /**
362         * Returns if <em>Morid Hatal</em> (or the lack of reciting <em>Mashiv Haruach</em> following <em>nussach Ashkenaz</em>) is
363         * recited. This period starts on the 15th day of {@link JewishDate#NISSAN <em>Nissan</em>} and ends on 22 {@link
364         * JewishDate#TISHREI <em>Tishrei</em>}.
365         * 
366         * @param jewishCalendar the Jewish calendar day.
367         * 
368         * @return true if <em>Morid Hatal</em> (or the lack of reciting <em>Mashiv Haruach</em> following <em>nussach Ashkenaz</em>) is recited.
369         */
370        public boolean isMoridHatalRecited(JewishCalendar jewishCalendar) {
371                return !isMashivHaruachRecited(jewishCalendar) || isMashivHaruachStartDate(jewishCalendar) || isMashivHaruachEndDate(jewishCalendar);
372        }
373        
374        /**
375         * Returns if <em>hallel</em> is recited on the day in question. This will return true for both <em>hallel shalem</em>
376         * and <em>chatzi hallel</em>. See {@link #isHallelShalemRecited(JewishCalendar)} to know if the complete <em>hallel</em>
377         * is recited.
378         * 
379         * @param jewishCalendar the Jewish calendar day.
380         * @return if <em>hallel</em> is recited.
381         * @see #isHallelShalemRecited(JewishCalendar)
382         */
383        public boolean isHallelRecited(JewishCalendar jewishCalendar) {
384                int day = jewishCalendar.getJewishDayOfMonth();
385                int month = jewishCalendar.getJewishMonth();
386                int holidayIndex = jewishCalendar.getYomTovIndex();
387                boolean inIsrael = jewishCalendar.getInIsrael();
388                
389                if(jewishCalendar.isRoshChodesh()) { //RH returns false for RC
390                        return true;
391                }
392                if(jewishCalendar.isChanukah()) {
393                        return true;
394                }
395                switch (month) {
396                        case JewishDate.NISSAN:
397                                if(day >= 15 && ((inIsrael && day <= 21) || (!inIsrael && day <= 22))){
398                                        return true;
399                                }
400                                break;
401                        case JewishDate.IYAR: // modern holidays
402                                if(jewishCalendar.isUseModernHolidays()  && (holidayIndex == JewishCalendar.YOM_HAATZMAUT
403                                                || holidayIndex == JewishCalendar.YOM_YERUSHALAYIM)){
404                                        return true;
405                                }
406                                break;
407                        case JewishDate.SIVAN:
408                                if (day == 6 || (!inIsrael && (day == 7))){
409                                        return true;
410                                }
411                                break;
412                        case JewishDate.TISHREI:
413                                if (day >= 15 && (day <= 22 || (!inIsrael && (day <= 23)))){
414                                        return true;
415                                }
416                }
417                return false;
418        }
419
420        /**
421         * Returns if <em>hallel shalem</em> is recited on the day in question. This will always return false if {@link
422         * #isHallelRecited(JewishCalendar)} returns false.
423         * 
424         * @param jewishCalendar the Jewish calendar day.
425         * @return if <em>hallel shalem</em> is recited.
426         * @see #isHallelRecited(JewishCalendar)
427         */
428        public boolean isHallelShalemRecited(JewishCalendar jewishCalendar) {
429                int day = jewishCalendar.getJewishDayOfMonth();
430                int month = jewishCalendar.getJewishMonth();
431                boolean inIsrael = jewishCalendar.getInIsrael();
432                if(isHallelRecited(jewishCalendar)) {
433                        if((jewishCalendar.isRoshChodesh() && ! jewishCalendar.isChanukah())
434                                        || (month == JewishDate.NISSAN && ((inIsrael && day > 15) || (!inIsrael && day > 16)))) {
435                                return false;
436                        } else {
437                                return true;
438                        }
439                } 
440                return false;
441        }
442        
443        /**
444         * Is <em>tachanun</em> recited during the week of Purim, from the 11th through the 17th of {@link
445         * JewishDate#ADAR <em>Adar</em>} (on a non-leap year, or {@link JewishDate#ADAR_II <em>Adar II</em>} on a leap year). Some
446         * <em>chasidishe</em> communities do not recite <em>tachanun</em> during this period. See the <a href=
447         * "https://www.nli.org.il/he/books/NNL_ALEPH001141272/NLI">Minhag Yisrael Torah</a> 131 and <a href=
448         * "https://hebrewbooks.org/pdfpager.aspx?req=4692&st=&pgnum=70">Darkei Chaim Veshalom 191</a>who discuss the
449         * <em>minhag</em> not to recite <em>tachanun</em>. Also see the <a href=
450         * "https://hebrewbooks.org/pdfpager.aspx?req=8944&st=&pgnum=160">Mishmeres Shalom (Hadras Shalom)</a> who discusses the
451         * <em>minhag</em> of not reciting it on the 16th and 17th.
452         * @return If <em>tachanun</em> is set to be recited during the week of Purim from the 11th through the 17th of {@link
453         *         JewishDate#ADAR <em>Adar</em>} (on a non-leap year, or {@link JewishDate#ADAR_II <em>Adar II</em>} on a leap year).
454         * @see #setTachanunRecitedWeekOfPurim(boolean)
455         */
456        public boolean isTachanunRecitedWeekOfPurim() {
457                return tachanunRecitedWeekOfPurim;
458        }
459
460        /**
461         * Sets if <em>tachanun</em> should be recited during the week of Purim from the 11th through the 17th of {@link
462         * JewishDate#ADAR <em>Adar</em>} (on a non-leap year), or {@link JewishDate#ADAR_II <em>Adar II</em>} (on a leap year).
463         * @param tachanunRecitedWeekOfPurim Sets if <em>tachanun</em> is to recited during the week of Purim from the 11th
464         *         through the 17th of {@link JewishDate#ADAR <em>Adar</em>} (on a non-leap year), or {@link JewishDate#ADAR_II
465         *         <em>Adar II</em>} (on a leap year). Some <em>chasidishe</em> communities do not recite <em>tachanun</em>
466         *         during this period.
467         * @see #isTachanunRecitedWeekOfPurim()
468         */
469        public void setTachanunRecitedWeekOfPurim(boolean tachanunRecitedWeekOfPurim) {
470                this.tachanunRecitedWeekOfPurim = tachanunRecitedWeekOfPurim;
471        }
472
473        /**
474         * Is <em>tachanun</em> recited during the <em>sefira</em> week of <em>Hod</em> (14 - 20 {@link JewishDate#IYAR <em>Iyar</em>},
475         * or the 29th - 35th of the {@link JewishCalendar#getDayOfOmer() <em>Omer</em>}). Some <em>chasidishe</em> communities
476         * do not recite <em>tachanun</em> during this week. See Minhag Yisrael Torah 131:Iyar.
477         * @return If <em>tachanun</em> is set to be recited during the <em>sefira</em> week of <em>Hod</em> (14 - 20 {@link
478         *         JewishDate#IYAR <em>Iyar</em>}, or the 29th - 35th of the {@link JewishCalendar#getDayOfOmer() <em>Omer</em>}).
479         * @see #setTachanunRecitedWeekOfHod(boolean)
480         */
481        public boolean isTachanunRecitedWeekOfHod() {
482                return tachanunRecitedWeekOfHod;
483        }
484
485        /**
486         * Sets if <em>tachanun</em> should be recited during the <em>sefira</em> week of <em>Hod</em> (14 - 20 {@link JewishDate#IYAR
487         * <em>Iyar</em>}, or the 29th - 35th of the {@link JewishCalendar#getDayOfOmer() <em>Omer</em>}).
488         * @param tachanunRecitedWeekOfHod Sets if <em>tachanun</em> should be recited during the <em>sefira</em> week of
489         * <em>Hod</em>.
490         * @see #isTachanunRecitedWeekOfHod()
491         */
492        public void setTachanunRecitedWeekOfHod(boolean tachanunRecitedWeekOfHod) {
493                this.tachanunRecitedWeekOfHod = tachanunRecitedWeekOfHod;
494        }
495
496        /**
497         * Is <em>tachanun</em> recited at the end Of {@link JewishDate#TISHREI <em>Tishrei</em>}.The Magen Avraham 669:1 and the Pri
498         * Chadash 131:7 state that some places to not recite <em>tachanun</em> during this period. The Sh"UT Chasam Sofer on Choshen
499         * Mishpat 77 writes that this is the <em>minhag</em> in Ashkenaz. The Shaarei Teshuva 131:19 quotes the Sheyarie Kneses
500         * Hagdola who also states that it should not be recited. The Aderes wanted to institute saying <em>tachanun</em> during this
501         * period, but was dissuaded from this by Rav Shmuel Salant who did not want to change the <em>minhag</em> in Yerushalayim.
502         * The Aruch Hashulchan is of the opinion that that this <em>minhag</em> is incorrect, and it should be recited, and The Chazon
503         * Ish also recited <em>tachanun</em> during this period. See the Dirshu edition of the Mishna Berurah for details.
504         * @return If <em>tachanun</em> is set to be recited at the end of {@link JewishDate#TISHREI <em>Tishrei</em>}.
505         * @see #setTachanunRecitedEndOfTishrei(tachanunRecitedEndOfTishrei)
506         */
507        public boolean isTachanunRecitedEndOfTishrei() {
508                return tachanunRecitedEndOfTishrei;
509        }
510
511        /**
512         * Sets if <em>tachanun</em> should be recited at the end of {@link JewishDate#TISHREI <em>Tishrei</em>}.
513         * @param tachanunRecitedEndOfTishrei is <em>tachanun</em> recited at the end of {@link JewishDate#TISHREI <em>Tishrei</em>}.
514         * @see #isTachanunRecitedEndOfTishrei()
515         */
516        public void setTachanunRecitedEndOfTishrei(boolean tachanunRecitedEndOfTishrei) {
517                this.tachanunRecitedEndOfTishrei = tachanunRecitedEndOfTishrei;
518        }
519        
520        /**
521         * Is <em>tachanun</em> recited during the week after <em>Shavuos</em>. This is the opinion of the Pri Megadim
522         * quoted by the Mishna Berurah. This is since <em>karbanos</em> of <em>Shavuos</em> have <em>tashlumim</em> for
523         * 7 days, it is still considered like a Yom Tov. The Chazon Ish quoted in the Orchos Rabainu vol. 1 page 68
524         * recited <em>tachanun</em> during this week.
525         * 
526         * @return If <em>tachanun</em> is set to be recited during the week after Shavuos.
527         * @see #setTachanunRecitedWeekAfterShavuos(boolean)
528         */
529        public boolean isTachanunRecitedWeekAfterShavuos() {
530                return tachanunRecitedWeekAfterShavuos;
531        }
532
533        /**
534         * Sets if <em>tachanun</em> should be recited during the week after <em>Shavuos</em>.
535         * @param tachanunRecitedWeekAfterShavuos is <em>tachanun</em> recited during the week after Shavuos.
536         * @see #isTachanunRecitedWeekAfterShavuos()
537         */
538        public void setTachanunRecitedWeekAfterShavuos(boolean tachanunRecitedWeekAfterShavuos) {
539                this.tachanunRecitedWeekAfterShavuos = tachanunRecitedWeekAfterShavuos;
540        }
541        
542        /**
543         * Is <em>tachanun</em> is recited on the 13th of {@link JewishDate#SIVAN <em>Sivan</em>} (<a href=
544         * "https://en.wikipedia.org/wiki/Yom_tov_sheni_shel_galuyot"><em>Yom Tov Sheni shel Galuyos</em></a> of the 7th
545         * day) outside Israel. This is brought down by the Shaarie Teshuva 131:19 quoting the <a href=
546         * "https://hebrewbooks.org/pdfpager.aspx?req=41295&st=&pgnum=39">Sheyarei Kneses Hagedola 131:12</a>that
547         * <em>tachanun</em> should not be recited on this day. Rav Shlomo Zalman Orbach in Halichos Shlomo on
548         * Shavuos 12:16:25 is of the opinion that even in <em>chutz laaretz</em> it should be recited since the <em>yemei
549         * Tashlumin</em> are counted based on Israel since that is where the <em>karbanos</em> are brought. Both
550         * {@link #isTachanunRecitedShacharis(JewishCalendar)} and {@link #isTachanunRecitedMincha(JewishCalendar)}
551         * only return false if the location is not set to {@link JewishCalendar#getInIsrael() Israel} and both
552         * {@link #tachanunRecitedWeekAfterShavuos} and {@link #setTachanunRecited13SivanOutOfIsrael} are set to false.
553         * 
554         * @return If <em>tachanun</em> is set to be recited on the 13th of {@link JewishDate#SIVAN <em>Sivan</em>} out of Israel.
555         * @see #setTachanunRecited13SivanOutOfIsrael(isTachanunRecitedThirteenSivanOutOfIsrael)
556         * @see #isTachanunRecitedWeekAfterShavuos()
557         */
558        public boolean isTachanunRecited13SivanOutOfIsrael() {
559                return tachanunRecited13SivanOutOfIsrael;
560        }
561
562        /**
563         * Sets if <em>tachanun</em> should be recited on the 13th of {@link JewishDate#SIVAN <em>Sivan</em>} (<a href=
564         * "https://en.wikipedia.org/wiki/Yom_tov_sheni_shel_galuyot"><em>Yom Tov Sheni shel Galuyos</em></a> of the 7th
565         * day) outside Israel. 
566         * @param tachanunRecitedThirteenSivanOutOfIsrael sets if <em>tachanun</em> should be recited on the 13th of {@link
567         *          JewishDate#SIVAN <em>Sivan</em>} out of Israel. Both {@link #isTachanunRecitedShacharis(JewishCalendar)} and
568         *          {@link #isTachanunRecitedMincha(JewishCalendar)} only return false if the location is not set to {@link
569         *          JewishCalendar#getInIsrael() Israel} and both {@link #tachanunRecitedWeekAfterShavuos} and
570         *          {@link #setTachanunRecited13SivanOutOfIsrael} are set to false.
571         * @see #isTachanunRecited13SivanOutOfIsrael()
572         */
573        public void setTachanunRecited13SivanOutOfIsrael(boolean tachanunRecitedThirteenSivanOutOfIsrael) {
574                this.tachanunRecited13SivanOutOfIsrael = tachanunRecitedThirteenSivanOutOfIsrael;
575        }
576        
577        /**
578         * Is <em>tachanun</em> recited on {@link JewishCalendar#PESACH_SHENI <em>Pesach Sheni</em>}. The Pri Chadash 131:7 states
579         * that <em>tachanun</em> should not be recited. The Aruch Hashulchan states that this is the minhag of the <em>sephardim</em>.
580         * the Shaarei Efraim 10:27 also mentions that it is not recited, as does the Siddur Yaavetz (Shaar Hayesod, Chodesh Iyar).
581         * The Pri Megadim (Mishbetzes Hazahav 131:15) and the Chazon Ish (Erev Pesahc Shchal Beshabos, page 203 in <a href=
582         * "https://he.wikipedia.org/wiki/%D7%A9%D7%A8%D7%99%D7%94_%D7%93%D7%91%D7%9C%D7%99%D7%A6%D7%A7%D7%99">Rav Sheraya
583         * Devlitzky's</a> comments).
584         * 
585         * @return If <em>tachanun</em> is recited on {@link JewishCalendar#PESACH_SHENI <em>Pesach Sheni</em>}.
586         * @see #setTachanunRecitedPesachSheni(boolean)
587         */
588        public boolean isTachanunRecitedPesachSheni() {
589                return tachanunRecitedPesachSheni;
590        }
591
592        /**
593         * Sets if <em>tachanun</em> should be recited on {@link JewishCalendar#PESACH_SHENI <em>Pesach Sheni</em>}.
594         * @param tachanunRecitedPesachSheni sets if <em>tachanun</em> should be recited on <em>Pesach Sheni</em>.
595         * @see #isTachanunRecitedPesachSheni()
596         */
597        public void setTachanunRecitedPesachSheni(boolean tachanunRecitedPesachSheni) {
598                this.tachanunRecitedPesachSheni = tachanunRecitedPesachSheni;
599        }
600        
601        /**
602         * Is <em>tachanun</em> recited on 15 {@link JewishDate#IYAR <em>Iyar</em>} (<em>sfaika deyoma</em> of {@link JewishCalendar#PESACH_SHENI
603         * <em>Pesach Sheni</em>}) out of Israel. If {@link #isTachanunRecitedPesachSheni()} is <code>true</code> this will be
604         * ignored even if <code>false</code>.
605         * 
606         * @return if <em>tachanun</em> is recited on 15 {@link JewishDate#IYAR <em>Iyar</em>}  (<em>sfaika deyoma</em> of {@link
607         *          JewishCalendar#PESACH_SHENI <em>Pesach Sheni</em>} out of Israel. If {@link #isTachanunRecitedPesachSheni()}
608         *          is <code>true</code> this will be ignored even if <code>false</code>.
609         * @see #setTachanunRecited15IyarOutOfIsrael(boolean)
610         * @see #setTachanunRecitedPesachSheni(boolean)
611         * @see #isTachanunRecitedPesachSheni()
612         */
613        public boolean isTachanunRecited15IyarOutOfIsrael() {
614                return tachanunRecited15IyarOutOfIsrael;
615        }
616
617        /**
618         * Sets if <em>tachanun</em> should be recited on the 15th of {@link JewishDate#IYAR <em>Iyar</em>}  (<a href=
619         * "https://en.wikipedia.org/wiki/Yom_tov_sheni_shel_galuyot"><em>Yom Tov Sheni shel Galuyos</em></a> of
620         * {@link JewishCalendar#PESACH_SHENI <em>Pesach Sheni</em>}) out of Israel. Ignored if {@link
621         * #isTachanunRecitedPesachSheni()} is <code>true</code>.
622         * 
623         * @param tachanunRecited15IyarOutOfIsrael if <em>tachanun</em> should be recited on the 15th of {@link JewishDate#IYAR
624         *          <em>Iyar</em>} (<em>sfaika deyoma</em> of {@link JewishCalendar#PESACH_SHENI <em>Pesach Sheni</em>}) out of Israel.
625         * @see #isTachanunRecited15IyarOutOfIsrael()
626         */
627        public void setTachanunRecited15IyarOutOfIsrael(boolean tachanunRecited15IyarOutOfIsrael) {
628                this.tachanunRecited15IyarOutOfIsrael = tachanunRecited15IyarOutOfIsrael;
629        }
630        
631        /**
632         * Is <em>tachanun</em> recited on <em>mincha</em> on <em>erev {@link JewishCalendar#LAG_BAOMER Lag Baomer}</em>.
633         * @return if <em>tachanun</em> is recited in <em>mincha</em> on <em>erev</em>
634         *          {@link JewishCalendar#LAG_BAOMER <em>Lag Baomer</em>}.
635         * @see #setTachanunRecitedMinchaErevLagBaomer(boolean)
636         */
637        public boolean isTachanunRecitedMinchaErevLagBaomer() {
638                return tachanunRecitedMinchaErevLagBaomer;
639        }
640
641        /**
642         * Sets if <em>tachanun</em> should be recited on <em>erev {@link JewishCalendar#LAG_BAOMER Lag Baomer}</em>.
643         * @param tachanunRecitedMinchaErevLagBaomer sets if <em>tachanun</em> should be recited on <em>mincha</em>
644         *          of <em>erev {@link JewishCalendar#LAG_BAOMER Lag Baomer}</em>.
645         * @see #isTachanunRecitedMinchaErevLagBaomer()
646         */
647        public void setTachanunRecitedMinchaErevLagBaomer(boolean tachanunRecitedMinchaErevLagBaomer) {
648                this.tachanunRecitedMinchaErevLagBaomer = tachanunRecitedMinchaErevLagBaomer;
649        }
650        
651        /**
652         * Is <em>tachanun</em> recited during the <em>Shivas Yemei Hamiluim</em>, from the 23 of {@link
653         * JewishDate#ADAR <em>Adar</em>} on a non-leap-year or {@link JewishDate#ADAR_II <em>Adar II</em>} on a
654         * leap year to the end of the month. Some <em>chasidishe</em> communities do not say <em>tachanun</em>
655         * during this week. See <a href="https://hebrewbooks.org/pdfpager.aspx?req=4692&st=&pgnum=70">Darkei
656         * Chaim Veshalom 191</a>.
657         * @return if <em>tachanun</em> is recited during the <em>Shivas Yemei Hamiluim</em>, from the 23 of {@link
658         *          JewishDate#ADAR <em>Adar</em>} on a non-leap-year or {@link JewishDate#ADAR_II <em>Adar II</em>}
659         *          on a leap year to the end of the month.
660         * @see #setTachanunRecitedShivasYemeiHamiluim(boolean)
661         */
662        public boolean isTachanunRecitedShivasYemeiHamiluim() {
663                return tachanunRecitedShivasYemeiHamiluim;
664        }
665
666        /**
667         * Sets if <em>tachanun</em> should be recited during the <em>Shivas Yemei Hamiluim</em>, from the 23 of
668         * {@link JewishDate#ADAR <em>Adar</em>} on a non-leap-year or {@link JewishDate#ADAR_II <em>Adar II</em>}
669         * on a leap year to the end of the month.
670         * @param tachanunRecitedShivasYemeiHamiluim sets if <em>tachanun</em> should be recited during the
671         *          <em>Shivas Yemei Hamiluim</em>.
672         * @see #isTachanunRecitedShivasYemeiHamiluim()
673         */
674        public void setTachanunRecitedShivasYemeiHamiluim(boolean tachanunRecitedShivasYemeiHamiluim) {
675                this.tachanunRecitedShivasYemeiHamiluim = tachanunRecitedShivasYemeiHamiluim;
676        }
677
678        /**
679         * Is <em>tachanun</em> recited on Fridays. Some <em>chasidishe</em> communities do not recite
680         * <em>tachanun</em> on Fridays. See <a href="https://hebrewbooks.org/pdfpager.aspx?req=41190&st=&pgnum=10">Likutei
681         * Maharich Vol 2 Seder Hanhagos Erev Shabbos</a>. This is also the <em>minhag</em> in Satmar.
682         * @return if <em>tachanun</em> is recited on Fridays.
683         * @see #setTachanunRecitedFridays(boolean)
684         */
685        public boolean isTachanunRecitedFridays() {
686                return tachanunRecitedFridays;
687        }
688
689        /**
690         * Sets if <em>tachanun</em> should be recited on Fridays. 
691         * @param tachanunRecitedFridays sets if <em>tachanun</em> should be recited on Fridays. Some <em>chasidishe</em>
692         *          communities do not recite <em>tachanun</em> on Fridays.
693         * @see #isTachanunRecitedFridays()
694         */
695        public void setTachanunRecitedFridays(boolean tachanunRecitedFridays) {
696                this.tachanunRecitedFridays = tachanunRecitedFridays;
697        }
698
699        /**
700         * Is <em>tachanun</em> recited on Sundays. Some <em>chasidishe</em> communities do not recite
701         * <em>tachanun</em> on Sundays. See <a href="https://hebrewbooks.org/pdfpager.aspx?req=41190&st=&pgnum=10">Likutei
702         * Maharich Vol 2 Seder Hanhagos Erev Shabbos</a>. 
703         * @return if <em>tachanun</em> is recited on Sundays.
704         * @see #setTachanunRecitedSundays(boolean)
705         */
706        public boolean isTachanunRecitedSundays() {
707                return tachanunRecitedSundays;
708        }
709
710        /**
711         * Sets if <em>tachanun</em> should be recited on Sundays. 
712         * @param tachanunRecitedSundays sets if <em>tachanun</em> should be recited on Sundays. Some <em>chasidishe</em>
713         *          communities do not recite <em>tachanun</em> on Sundays.
714         * @see #isTachanunRecitedSundays()
715         */
716        public void setTachanunRecitedSundays(boolean tachanunRecitedSundays) {
717                this.tachanunRecitedSundays = tachanunRecitedSundays;
718        }
719        
720        /**
721         * Is <em>tachanun</em> recited in <em>Mincha</em> the entire year. Some <em>chasidishe</em> communities do not recite
722         * <em>tachanun</em> by <em>Mincha</em> all year round. See<a href=
723         * "https://hebrewbooks.org/pdfpager.aspx?req=4751&st=&pgnum=105">Nemukei Orach Chaim 131:3</a>.
724         * @return if <em>tachanun</em> is recited in <em>Mincha</em> the entire year.
725         * @see #setTachanunRecitedMinchaAllYear(boolean)
726         */
727        public boolean isTachanunRecitedMinchaAllYear() {
728                return tachanunRecitedMinchaAllYear;
729        }
730
731        /**
732         * Sets if <em>tachanun</em> should be recited in <em>Mincha</em> the entire year.
733         * @param tachanunRecitedMinchaAllYear sets if <em>tachanun</em> should be recited by <em>mincha</em> all year. If set
734         *          to false, {@link #isTachanunRecitedMincha(JewishCalendar)} will always return false. If set to true (the
735         *          default), it will use the regular rules.
736         * @see #isTachanunRecitedMinchaAllYear()
737         */
738        public void setTachanunRecitedMinchaAllYear(boolean tachanunRecitedMinchaAllYear) {
739                this.tachanunRecitedMinchaAllYear = tachanunRecitedMinchaAllYear;
740        }
741}