From 45878e64e76b6d16b3edcd48e23cb2fb4e33499a Mon Sep 17 00:00:00 2001 From: noamtu123 Date: Wed, 1 Jul 2026 12:30:57 +0300 Subject: [PATCH 1/5] Add offline Limud Yomi calculators --- .../hebrewcalendar/HebrewDateFormatter.java | 168 +++++++ .../zmanim/hebrewcalendar/JewishCalendar.java | 56 +++ .../KitzurShulchanAruchYomi.java | 27 ++ .../KitzurShulchanAruchYomiCalculator.java | 61 +++ .../zmanim/hebrewcalendar/LimudYomiData.java | 102 ++++ .../zmanim/hebrewcalendar/MishnaYomi.java | 81 ++++ .../hebrewcalendar/MishnaYomiCalculator.java | 58 +++ .../zmanim/hebrewcalendar/RambamYomi.java | 59 +++ .../hebrewcalendar/RambamYomiCalculator.java | 62 +++ .../hebrewcalendar/ShemirasHaLashonYomi.java | 39 ++ .../ShemirasHaLashonYomiCalculator.java | 447 ++++++++++++++++++ .../zmanim/hebrewcalendar/TanachYomi.java | 33 ++ .../hebrewcalendar/TanachYomiCalculator.java | 198 ++++++++ .../zmanim/hebrewcalendar/TehillimYomi.java | 27 ++ .../TehillimYomiCalculator.java | 29 ++ .../LimudYomiCalculatorTest.java | 78 +++ 16 files changed, 1525 insertions(+) create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomi.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomiCalculator.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiData.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomi.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomiCalculator.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomi.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomiCalculator.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomi.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomiCalculator.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomi.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomiCalculator.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomi.java create mode 100644 src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomiCalculator.java create mode 100644 src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java index 4e1a7bdb..c91f1815 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java @@ -824,6 +824,174 @@ public String formatDafYomiYerushalmi(Daf daf) { } } + /** + * Formats the Mishna Yomi reading. + * @param mishnaYomi the Mishna Yomi to be formatted. + * @return the formatted Mishna Yomi. + */ + public String formatMishnaYomi(MishnaYomi mishnaYomi) { + String start = (hebrewFormat ? mishnaYomi.getMasechta() + " " + formatHebrewNumber(mishnaYomi.getStartChapter()) + + ": " + formatPlainHebrewNumber(mishnaYomi.getStartMishna()) : mishnaYomi.getMasechtaTransliterated() + " " + + mishnaYomi.getStartChapter() + ":" + mishnaYomi.getStartMishna()); + if (mishnaYomi.getStartMasechtaNumber() == mishnaYomi.getEndMasechtaNumber() + && mishnaYomi.getStartChapter() == mishnaYomi.getEndChapter()) { + return start + "-" + (hebrewFormat ? formatPlainHebrewNumber(mishnaYomi.getEndMishna()) : mishnaYomi.getEndMishna()); + } + return start + "-" + (hebrewFormat ? mishnaYomi.getEndMasechta() + " " + formatHebrewNumber(mishnaYomi.getEndChapter()) + + ": " + formatPlainHebrewNumber(mishnaYomi.getEndMishna()) : mishnaYomi.getEndMasechtaTransliterated() + " " + + mishnaYomi.getEndChapter() + ":" + mishnaYomi.getEndMishna()); + } + + /** + * Formats the daily Rambam reading. + * @param rambamYomi the Rambam Yomi to be formatted. + * @return the formatted Rambam Yomi. + */ + public String formatRambamYomi(RambamYomi rambamYomi) { + if (hebrewFormat) { + if (rambamYomi.getBookNumber() != rambamYomi.getEndBookNumber()) { + return "הלכות " + rambamYomi.getHebrewName() + " פרק " + formatPlainHebrewNumber(rambamYomi.getStartChapter()) + + " - הלכות " + rambamYomi.getEndHebrewName() + " פרק " + formatPlainHebrewNumber(rambamYomi.getEndChapter()); + } + String chapterPrefix = rambamYomi.getStartChapter() == rambamYomi.getEndChapter() ? " פרק " : " פרקים "; + String chapters = formatPlainHebrewNumber(rambamYomi.getStartChapter()); + if (rambamYomi.getStartChapter() != rambamYomi.getEndChapter()) { + chapters += "-" + formatPlainHebrewNumber(rambamYomi.getEndChapter()); + } + return "הלכות " + rambamYomi.getHebrewName() + chapterPrefix + chapters; + } + if (rambamYomi.getBookNumber() != rambamYomi.getEndBookNumber()) { + return rambamYomi.getName() + " " + rambamYomi.getStartChapter() + "-" + rambamYomi.getEndName() + " " + + rambamYomi.getEndChapter(); + } + return rambamYomi.getName() + " " + rambamYomi.getStartChapter() + + (rambamYomi.getStartChapter() == rambamYomi.getEndChapter() ? "" : "-" + rambamYomi.getEndChapter()); + } + + /** + * Formats the daily Tehillim reading. + * @param tehillimYomi the daily Tehillim to be formatted. + * @return the formatted daily Tehillim. + */ + public String formatDailyTehillim(TehillimYomi tehillimYomi) { + if (hebrewFormat) { + return "תהילים " + formatHebrewNumber(tehillimYomi.getStartChapter()) + + (tehillimYomi.getStartChapter() == tehillimYomi.getEndChapter() ? "" : "-" + formatHebrewNumber(tehillimYomi.getEndChapter())); + } + return "Psalms " + tehillimYomi.getStartChapter() + + (tehillimYomi.getStartChapter() == tehillimYomi.getEndChapter() ? "" : "-" + tehillimYomi.getEndChapter()); + } + + /** + * Formats the Tanach Yomi reading. + * @param tanachYomi the Tanach Yomi to be formatted. + * @return the formatted Tanach Yomi. + */ + public String formatTanachYomi(TanachYomi tanachYomi) { + if (tanachYomi == null) { + return ""; + } + if (hebrewFormat) { + String[] parts = tanachYomi.getSeder().split("\\."); + String seder = " ס׳ " + formatHebrewNumber(Integer.parseInt(parts[0])); + if (parts.length > 1) { + seder += " " + formatHebrewNumber(Integer.parseInt(parts[1])); + } + return tanachYomi.getHebrewBook() + seder; + } + return tanachYomi.getBook() + " Seder " + tanachYomi.getSeder(); + } + + /** + * Formats the Kitzur Shulchan Aruch Yomi reading. + * @param kitzurYomi the Kitzur Shulchan Aruch Yomi to be formatted. + * @return the formatted Kitzur Shulchan Aruch Yomi. + */ + public String formatKitzurShulchanAruchYomi(KitzurShulchanAruchYomi kitzurYomi) { + if (kitzurYomi == null) { + return ""; + } + if (kitzurYomi.getStart().equals(kitzurYomi.getEnd())) { + return formatKitzurRef(kitzurYomi.getStart()); + } + String[] start = kitzurYomi.getStart().split(":"); + String[] end = kitzurYomi.getEnd().split(":"); + if (start.length > 1 && end.length > 1 && start[0].equals(end[0])) { + return formatKitzurRef(kitzurYomi.getStart()) + "-" + (hebrewFormat ? formatPlainHebrewToken(end[1]) : end[1]); + } + return formatKitzurRef(kitzurYomi.getStart()) + (hebrewFormat ? " - " : "-") + formatKitzurRef(kitzurYomi.getEnd()); + } + + /** + * Formats the Shemiras HaLashon Yomi reading. + * @param shemirasYomi the Shemiras HaLashon Yomi to be formatted. + * @return the formatted Shemiras HaLashon Yomi. + */ + public String formatShemirasHaLashonYomi(ShemirasHaLashonYomi shemirasYomi) { + if (shemirasYomi == null) { + return ""; + } + if (hebrewFormat) { + return formatShemirasRef(shemirasYomi.getStart()) + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" + : (sameShemirasKlal(shemirasYomi.getStart(), shemirasYomi.getEnd()) ? "-" + shemirasHalacha(shemirasYomi.getEnd()) + : " - " + formatShemirasRef(shemirasYomi.getEnd()))); + } + String prefix = "Book " + (shemirasYomi.getBook() == 1 ? "I" : "II") + " "; + return prefix + shemirasYomi.getStart() + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" : "-" + shemirasYomi.getEnd()); + } + + private String formatKitzurRef(String ref) { + String[] parts = ref.split(":"); + if (hebrewFormat) { + return formatHebrewToken(parts[0]) + (parts.length > 1 ? ": " + formatPlainHebrewToken(parts[1]) : ""); + } + return ref; + } + + private String formatShemirasRef(String ref) { + String[] parts = ref.split("\\."); + return "כלל " + formatHebrewNumber(Integer.parseInt(parts[0])) + " " + (parts.length > 1 ? formatPlainHebrewToken(parts[1]) : ""); + } + + private boolean sameShemirasKlal(String start, String end) { + return start.split("\\.")[0].equals(end.split("\\.")[0]); + } + + private String shemirasHalacha(String ref) { + String[] parts = ref.split("\\."); + return parts.length > 1 ? formatPlainHebrewToken(parts[1]) : ""; + } + + private String formatHebrewToken(String token) { + if ("E".equals(token)) { + return "סוף"; + } + if ("Shmita".equals(token)) { + return "שמיטה"; + } + if ("Klalim".equals(token)) { + return "כללים"; + } + return formatHebrewNumber(Integer.parseInt(token)); + } + + private String formatPlainHebrewToken(String token) { + if ("E".equals(token)) { + return "סוף"; + } + if ("Shmita".equals(token)) { + return "שמיטה"; + } + if ("Klalim".equals(token)) { + return "כללים"; + } + return formatPlainHebrewNumber(Integer.parseInt(token)); + } + + private String formatPlainHebrewNumber(int number) { + return formatHebrewNumber(number).replace(GERESH, "").replace(GERSHAYIM, ""); + } + /** * Returns a Hebrew formatted string of a number. The method can calculate from 0 to 9999. * * @author © Eliyahu Hershfeld 2011 - 2026 */ diff --git a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java index 59c17dcb..f98bdc82 100644 --- a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java +++ b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java @@ -28,6 +28,21 @@ public void testRambamYomiOneChapter() { "הלכות שבת פרק יז", hebrewFormatter.formatRambamYomi(calendar.getRambamYomi())); } + @Test + public void testRambamYomiIntroAndSpecialChapters() { + JewishCalendar calendar = new JewishCalendar(LocalDate.of(1984, 4, 29)); + Assert.assertEquals( + "Transmission of the Oral Law 1-21", formatter.formatRambamYomi(calendar.getRambamYomi())); + Assert.assertEquals( + "מסירת תורה שבעל פה פרק א-כא", hebrewFormatter.formatRambamYomi(calendar.getRambamYomi())); + + calendar = new JewishCalendar(LocalDate.of(2023, 8, 8)); + Assert.assertEquals( + "The Order of Prayer 4-5", formatter.formatRambamYomi(calendar.getRambamYomi())); + Assert.assertEquals( + "סדר התפילה פרקים ד-ה", hebrewFormatter.formatRambamYomi(calendar.getRambamYomi())); + } + @Test public void testRambamYomiThreeChapters() { JewishCalendar calendar = new JewishCalendar(LocalDate.of(2024, 7, 29)); @@ -38,6 +53,25 @@ public void testRambamYomiThreeChapters() { hebrewFormatter.formatRambamYomi(calendar.getRambamYomi3Chapters())); } + @Test + public void testRambamYomiThreeChapterSpecialCases() { + JewishCalendar calendar = new JewishCalendar(LocalDate.of(1984, 4, 29)); + Assert.assertEquals( + "Transmission of the Oral Law 1-45", + formatter.formatRambamYomi(calendar.getRambamYomi3Chapters())); + Assert.assertEquals( + "מסירת תורה שבעל פה פרקים א-מה", + hebrewFormatter.formatRambamYomi(calendar.getRambamYomi3Chapters())); + + calendar = new JewishCalendar(LocalDate.of(2020, 9, 3)); + Assert.assertEquals( + "Leavened and Unleavened Bread 8-9, Shofar, Sukkah and Lulav 1-2", + formatter.formatRambamYomi(calendar.getRambamYomi3Chapters())); + Assert.assertEquals( + "הלכות חמץ ומצה פרקים ח-ט, הלכות שופר וסוכה ולולב פרקים א-ב", + hebrewFormatter.formatRambamYomi(calendar.getRambamYomi3Chapters())); + } + @Test public void testDailyTehillim() { JewishCalendar calendar = new JewishCalendar(LocalDate.of(2024, 1, 3)); @@ -75,4 +109,15 @@ public void testShemirasHaLashonYomi() { "כלל ט׳ ח-י", hebrewFormatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); } + + @Test + public void testShemirasHaLashonSectionYomi() { + JewishCalendar calendar = new JewishCalendar(LocalDate.of(2024, 10, 3)); + Assert.assertEquals( + "Book I, Hakdamah 1-2", + formatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); + Assert.assertEquals( + "הקדמה א-ב", + hebrewFormatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); + } } From 651583dcb513f7a4349a3980916a936e7a0fc388 Mon Sep 17 00:00:00 2001 From: noamtu123 Date: Wed, 1 Jul 2026 16:16:07 +0300 Subject: [PATCH 3/5] Adjust Shemirat HaLashon formatting --- .../hebrewcalendar/HebrewDateFormatter.java | 19 +++++++++++++++++-- .../LimudYomiCalculatorTest.java | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java index 72f5699d..42c13054 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java @@ -944,8 +944,13 @@ public String formatShemirasHaLashonYomi(ShemirasHaLashonYomi shemirasYomi) { return formatShemirasSection(shemirasYomi.getSection()) + " " + formatShemirasSectionRef(shemirasYomi.getStart()) + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" : formatShemirasSectionRangeEnd(shemirasYomi.getStart(), shemirasYomi.getEnd())); } - String prefix = "Book " + (shemirasYomi.getBook() == 1 ? "I" : "II") + ("x".equals(shemirasYomi.getSection()) ? " " : ", " + shemirasYomi.getSection() + " "); - return prefix + shemirasYomi.getStart() + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" : "-" + shemirasYomi.getEnd()); + if ("x".equals(shemirasYomi.getSection())) { + return formatShemirasEnglishKlalRef(shemirasYomi.getStart()) + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" + : (sameShemirasKlal(shemirasYomi.getStart(), shemirasYomi.getEnd()) ? "-" + shemirasHalachaEnglish(shemirasYomi.getEnd()) + : " - " + formatShemirasEnglishKlalRef(shemirasYomi.getEnd()))); + } + return "Shemirat HaLashon, " + shemirasYomi.getSection() + " " + shemirasYomi.getStart() + + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" : "-" + shemirasYomi.getEnd()); } private String formatKitzurRef(String ref) { @@ -985,6 +990,11 @@ private String formatShemirasKlalRef(String ref) { return "כלל " + formatHebrewNumber(Integer.parseInt(parts[0])) + " " + (parts.length > 1 ? formatPlainHebrewToken(parts[1]) : ""); } + private String formatShemirasEnglishKlalRef(String ref) { + String[] parts = ref.split("\\."); + return "Klal " + parts[0] + " Halacha " + (parts.length > 1 ? parts[1] : ""); + } + private String formatShemirasSection(String section) { if ("Hakdamah".equals(section)) { return "הקדמה"; @@ -1027,6 +1037,11 @@ private String shemirasHalacha(String ref) { return parts.length > 1 ? formatPlainHebrewToken(parts[1]) : ""; } + private String shemirasHalachaEnglish(String ref) { + String[] parts = ref.split("\\."); + return parts.length > 1 ? parts[1] : ""; + } + private String formatHebrewToken(String token) { if ("E".equals(token)) { return "סוף"; diff --git a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java index f98bdc82..9222e322 100644 --- a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java +++ b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java @@ -103,7 +103,7 @@ public void testKitzurShulchanAruchYomi() { public void testShemirasHaLashonYomi() { JewishCalendar calendar = new JewishCalendar(LocalDate.of(2024, 6, 26)); Assert.assertEquals( - "Book II 9.8-9.10", + "Klal 9 Halacha 8-10", formatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); Assert.assertEquals( "כלל ט׳ ח-י", @@ -114,7 +114,7 @@ public void testShemirasHaLashonYomi() { public void testShemirasHaLashonSectionYomi() { JewishCalendar calendar = new JewishCalendar(LocalDate.of(2024, 10, 3)); Assert.assertEquals( - "Book I, Hakdamah 1-2", + "Shemirat HaLashon, Hakdamah 1-2", formatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); Assert.assertEquals( "הקדמה א-ב", From 50616ec53ca9919f2ef2d1d213aa19d82d7e3186 Mon Sep 17 00:00:00 2001 From: noamtu123 Date: Wed, 1 Jul 2026 16:38:32 +0300 Subject: [PATCH 4/5] Polish Limud Yomi calculators --- .../hebrewcalendar/HebrewDateFormatter.java | 10 +++- .../KitzurShulchanAruchYomi.java | 7 +++ .../KitzurShulchanAruchYomiCalculator.java | 19 ++++++- .../zmanim/hebrewcalendar/LimudYomiData.java | 7 +++ .../zmanim/hebrewcalendar/MishnaYomi.java | 7 +++ .../hebrewcalendar/MishnaYomiCalculator.java | 18 +++++- .../zmanim/hebrewcalendar/RambamYomi.java | 18 +++++- .../hebrewcalendar/RambamYomiCalculator.java | 32 ++++++++++- .../hebrewcalendar/ShemirasHaLashonYomi.java | 7 +++ .../ShemirasHaLashonYomiCalculator.java | 22 +++++++- .../zmanim/hebrewcalendar/TanachYomi.java | 7 +++ .../hebrewcalendar/TanachYomiCalculator.java | 17 +++++- .../zmanim/hebrewcalendar/TehillimYomi.java | 7 +++ .../TehillimYomiCalculator.java | 55 +++++++++++++++++-- .../LimudYomiCalculatorTest.java | 8 +++ 15 files changed, 224 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java index 42c13054..d8bec5ed 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java @@ -831,14 +831,14 @@ public String formatDafYomiYerushalmi(Daf daf) { */ public String formatMishnaYomi(MishnaYomi mishnaYomi) { String start = (hebrewFormat ? mishnaYomi.getMasechta() + " " + formatHebrewNumber(mishnaYomi.getStartChapter()) - + ": " + formatPlainHebrewNumber(mishnaYomi.getStartMishna()) : mishnaYomi.getMasechtaTransliterated() + " " + + ": " + formatMishnaNumber(mishnaYomi.getStartMishna()) : mishnaYomi.getMasechtaTransliterated() + " " + mishnaYomi.getStartChapter() + ":" + mishnaYomi.getStartMishna()); if (mishnaYomi.getStartMasechtaNumber() == mishnaYomi.getEndMasechtaNumber() && mishnaYomi.getStartChapter() == mishnaYomi.getEndChapter()) { - return start + "-" + (hebrewFormat ? formatPlainHebrewNumber(mishnaYomi.getEndMishna()) : mishnaYomi.getEndMishna()); + return start + "-" + (hebrewFormat ? formatMishnaNumber(mishnaYomi.getEndMishna()) : mishnaYomi.getEndMishna()); } return start + "-" + (hebrewFormat ? mishnaYomi.getEndMasechta() + " " + formatHebrewNumber(mishnaYomi.getEndChapter()) - + ": " + formatPlainHebrewNumber(mishnaYomi.getEndMishna()) : mishnaYomi.getEndMasechtaTransliterated() + " " + + ": " + formatMishnaNumber(mishnaYomi.getEndMishna()) : mishnaYomi.getEndMasechtaTransliterated() + " " + mishnaYomi.getEndChapter() + ":" + mishnaYomi.getEndMishna()); } @@ -1080,6 +1080,10 @@ private String formatPlainHebrewNumber(int number) { return formatHebrewNumber(number).replace(GERESH, "").replace(GERSHAYIM, ""); } + private String formatMishnaNumber(int number) { + return formatHebrewNumber(number).replace(GERESH, ""); + } + /** * Returns a Hebrew formatted string of a number. The method can calculate from 0 to 9999. *
    diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomi.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomi.java index f017fb88..b1fd6951 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomi.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomi.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomiCalculator.java index a7d799e1..29eff5f0 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/KitzurShulchanAruchYomiCalculator.java @@ -4,13 +4,30 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; -/** Calculates the annual Hebrew-date Kitzur Shulchan Aruch Yomi schedule. */ +/** + * Calculates the annual Hebrew-date Kitzur Shulchan Aruch Yomi schedule. The schedule repeats every + * Hebrew year. It returns {@code null} for dates that do not have a regular table entry, such as 30 + * Cheshvan and 30 Adar I. + */ public class KitzurShulchanAruchYomiCalculator { public KitzurShulchanAruchYomiCalculator() {} + /** + * Returns the Kitzur Shulchan Aruch Yomi reading for the date that the calendar is set to. + * + * @param calendar the calendar set to the date to calculate + * @return the Kitzur Shulchan Aruch Yomi reading, or {@code null} on days without a reading + */ public static KitzurShulchanAruchYomi getKitzurShulchanAruchYomi(JewishCalendar calendar) { int month = calendar.getJewishMonth(); int day = calendar.getJewishDayOfMonth(); diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiData.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiData.java index 04111996..387d13eb 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiData.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiData.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomi.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomi.java index a96e29b7..4eaa8a82 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomi.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomi.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomiCalculator.java index ed601888..7edfff70 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/MishnaYomiCalculator.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; @@ -11,7 +18,9 @@ import java.time.temporal.ChronoUnit; /** - * Calculates Mishna Yomi, the two-mishnayos-a-day cycle that began on May 20, 1947 / 1 Sivan 5707. + * Calculates Mishna Yomi, the cycle of learning two mishnayos a day. The cycle began on + * May 20, 1947 / 1 Sivan 5707 and repeats every 2,096 days. The schedule is calculated offline from + * the number of mishnayos in each chapter of Shisha Sidrei Mishna. */ public class MishnaYomiCalculator { private static final LocalDate START = LocalDate.of(1947, 5, 20); @@ -19,6 +28,13 @@ public class MishnaYomiCalculator { public MishnaYomiCalculator() {} + /** + * Returns the Mishna Yomi for the date that the calendar is set to. + * + * @param calendar the calendar set to the date to calculate + * @return the Mishna Yomi reading + * @throws IllegalArgumentException if the date is before May 20, 1947, the start of the cycle + */ public static MishnaYomi getMishnaYomi(JewishCalendar calendar) { LocalDate date = calendar.getLocalDate(); if (date.isBefore(START)) { diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomi.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomi.java index 4ae6d2a7..72f575b9 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomi.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomi.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; @@ -26,9 +33,14 @@ public RambamYomi(int bookNumber, String startChapter, String endChapter) { } public RambamYomi(int[] bookNumbers, String[] startChapters, String[] endChapters) { - this.bookNumbers = bookNumbers; - this.startChapters = startChapters; - this.endChapters = endChapters; + if (bookNumbers.length == 0 + || bookNumbers.length != startChapters.length + || bookNumbers.length != endChapters.length) { + throw new IllegalArgumentException("Rambam readings must have matching non-empty arrays"); + } + this.bookNumbers = bookNumbers.clone(); + this.startChapters = startChapters.clone(); + this.endChapters = endChapters.clone(); } public int getReadingCount() { diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomiCalculator.java index c2c33422..76e0993c 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/RambamYomiCalculator.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; @@ -12,7 +19,9 @@ /** * Calculates the one and three chapter daily Rambam Mishneh Torah cycles that began on April 29, - * 1984 / 27 Nisan 5744. + * 1984 / 27 Nisan 5744. The one chapter cycle repeats every 1,017 days and the three chapter cycle + * repeats every 339 days. The opening introduction sections and the published special groupings in + * Seder Tefilos and Hilchos Chametz U'Matzah are handled offline. */ public class RambamYomiCalculator { private static final LocalDate START = LocalDate.of(1984, 4, 29); @@ -26,10 +35,24 @@ public class RambamYomiCalculator { public RambamYomiCalculator() {} + /** + * Returns the one chapter daily Rambam reading for the date that the calendar is set to. + * + * @param calendar the calendar set to the date to calculate + * @return the one chapter Rambam Yomi reading + * @throws IllegalArgumentException if the date is before April 29, 1984, the start of the cycle + */ public static RambamYomi getRambamYomi(JewishCalendar calendar) { return getRambamYomi1Chapter(calendar); } + /** + * Returns the one chapter daily Rambam reading for the date that the calendar is set to. + * + * @param calendar the calendar set to the date to calculate + * @return the one chapter Rambam Yomi reading + * @throws IllegalArgumentException if the date is before April 29, 1984, the start of the cycle + */ public static RambamYomi getRambamYomi1Chapter(JewishCalendar calendar) { int d = day(calendar, ONE_CHAPTER_CYCLE); RambamYomi reading = chapterAt(d, LimudYomiData.RAMBAM_CHAPTERS); @@ -40,6 +63,13 @@ public static RambamYomi getRambamYomi1Chapter(JewishCalendar calendar) { return reading; } + /** + * Returns the three chapter daily Rambam reading for the date that the calendar is set to. + * + * @param calendar the calendar set to the date to calculate + * @return the three chapter Rambam Yomi reading, collapsed by adjacent Mishneh Torah section + * @throws IllegalArgumentException if the date is before April 29, 1984, the start of the cycle + */ public static RambamYomi getRambamYomi3Chapters(JewishCalendar calendar) { int d = day(calendar, ONE_CHAPTER_CYCLE / 3) * 3; int[] chapters = LimudYomiData.RAMBAM_CHAPTERS.clone(); diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomi.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomi.java index b140cec9..475162af 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomi.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomi.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomiCalculator.java index 3e098e2e..92ba637e 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/ShemirasHaLashonYomiCalculator.java @@ -4,12 +4,24 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; import java.time.LocalDate; -/** Calculates the annual Hebrew-date Shemiras HaLashon Yomi schedule. */ +/** + * Calculates the annual Hebrew-date Shemiras HaLashon Yomi schedule. The cycle follows the + * published calendar-date schedule for Sefer Shemiras HaLashon and has separate common-year and + * leap-year date columns. Short Cheshvan and Kislev years combine the missing 30th day with the + * 29th day. + */ public class ShemirasHaLashonYomiCalculator { private static final LocalDate START = LocalDate.of(1876, 2, 16); private static final String[][] SCHEDULE = { @@ -402,6 +414,14 @@ public class ShemirasHaLashonYomiCalculator { public ShemirasHaLashonYomiCalculator() {} + /** + * Returns the Shemiras HaLashon Yomi reading for the date that the calendar is set to. + * + * @param calendar the calendar set to the date to calculate + * @return the Shemiras HaLashon Yomi reading + * @throws IllegalArgumentException if the date is before February 16, 1876, the start of the + * cycle + */ public static ShemirasHaLashonYomi getShemirasHaLashonYomi(JewishCalendar calendar) { if (calendar.getLocalDate().isBefore(START)) { throw new IllegalArgumentException( diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomi.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomi.java index 24d79082..dd0fa7f0 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomi.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomi.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomiCalculator.java index a54d40a6..83eadf9b 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TanachYomiCalculator.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; @@ -11,7 +18,8 @@ /** * Calculates Tanach Yomi according to the annual Masoretic seder cycle that began on October 26, - * 1948 / 23 Tishrei 5709. + * 1948 / 23 Tishrei 5709. The cycle starts each year on 23 Tishrei and skips Shabbos and selected + * Jewish holidays. It returns {@code null} on skipped days. */ public class TanachYomiCalculator { private static final LocalDate START = LocalDate.of(1948, 10, 26); @@ -69,6 +77,13 @@ public class TanachYomiCalculator { public TanachYomiCalculator() {} + /** + * Returns the Tanach Yomi seder for the date that the calendar is set to. + * + * @param calendar the calendar set to the date to calculate + * @return the Tanach Yomi reading, or {@code null} on days without a reading + * @throws IllegalArgumentException if the date is before October 26, 1948, the start of the cycle + */ public static TanachYomi getTanachYomi(JewishCalendar calendar) { if (calendar.getLocalDate().isBefore(START)) { throw new IllegalArgumentException( diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomi.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomi.java index 846df742..0d1672cd 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomi.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomi.java @@ -4,6 +4,13 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomiCalculator.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomiCalculator.java index 81282138..b8eaf21d 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomiCalculator.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/TehillimYomiCalculator.java @@ -4,21 +4,64 @@ * * 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; version 2.1 of the License. + * + * 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 + * 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 */ package com.kosherjava.zmanim.hebrewcalendar; - -/** Calculates the daily Tehillim cycle divided by Hebrew day of month. */ +/** + * Calculates the daily Tehillim cycle divided by the Hebrew day of month. In a 29-day Hebrew month, + * the 30th day's portion is combined with the 29th day so that Sefer Tehillim is completed every + * month. + */ public class TehillimYomiCalculator { private static final int[][] SCHEDULE = { - {0, 0}, {1, 9}, {10, 17}, {18, 22}, {23, 28}, {29, 34}, {35, 38}, {39, 43}, {44, 48}, {49, 54}, - {55, 59}, {60, 65}, {66, 68}, {69, 71}, {72, 76}, {77, 78}, {79, 82}, {83, 87}, {88, 89}, - {90, 96}, {97, 103}, {104, 105}, {106, 107}, {108, 112}, {113, 118}, {119, 119}, {119, 119}, - {120, 134}, {135, 139}, {140, 144}, {145, 150} + {0, 0}, + {1, 9}, + {10, 17}, + {18, 22}, + {23, 28}, + {29, 34}, + {35, 38}, + {39, 43}, + {44, 48}, + {49, 54}, + {55, 59}, + {60, 65}, + {66, 68}, + {69, 71}, + {72, 76}, + {77, 78}, + {79, 82}, + {83, 87}, + {88, 89}, + {90, 96}, + {97, 103}, + {104, 105}, + {106, 107}, + {108, 112}, + {113, 118}, + {119, 119}, + {119, 119}, + {120, 134}, + {135, 139}, + {140, 144}, + {145, 150} }; public TehillimYomiCalculator() {} + /** + * Returns the daily Tehillim for the date that the calendar is set to. + * + * @param calendar the calendar set to the date to calculate + * @return the daily Tehillim reading + */ public static TehillimYomi getDailyTehillim(JewishCalendar calendar) { int day = calendar.getJewishDayOfMonth(); if (day == 29 && calendar.getDaysInJewishMonth() == 29) { diff --git a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java index 9222e322..0231db53 100644 --- a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java +++ b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java @@ -20,6 +20,14 @@ public void testMishnaYomi() { "כלים י״א: ז-ח", hebrewFormatter.formatMishnaYomi(calendar.getMishnaYomi())); } + @Test + public void testMishnaYomiHebrewFifteen() { + JewishCalendar calendar = new JewishCalendar(LocalDate.of(2020, 10, 18)); + Assert.assertEquals("Kelim 17:14-15", formatter.formatMishnaYomi(calendar.getMishnaYomi())); + Assert.assertEquals( + "כלים י״ז: י״ד-ט״ו", hebrewFormatter.formatMishnaYomi(calendar.getMishnaYomi())); + } + @Test public void testRambamYomiOneChapter() { JewishCalendar calendar = new JewishCalendar(LocalDate.of(2020, 11, 11)); From 21caae067acbdbeac16cd30cc22adda6b78d3421 Mon Sep 17 00:00:00 2001 From: noamtu123 Date: Thu, 2 Jul 2026 09:16:33 +0300 Subject: [PATCH 5/5] Improve Shemiras HaLashon formatting --- .../hebrewcalendar/HebrewDateFormatter.java | 71 ++++++++++++++----- .../LimudYomiCalculatorTest.java | 19 +++-- 2 files changed, 69 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java index d8bec5ed..22016429 100644 --- a/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java +++ b/src/main/java/com/kosherjava/zmanim/hebrewcalendar/HebrewDateFormatter.java @@ -936,21 +936,19 @@ public String formatShemirasHaLashonYomi(ShemirasHaLashonYomi shemirasYomi) { return ""; } if (hebrewFormat) { - if ("x".equals(shemirasYomi.getSection())) { - return formatShemirasKlalRef(shemirasYomi.getStart()) + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" - : (sameShemirasKlal(shemirasYomi.getStart(), shemirasYomi.getEnd()) ? "-" + shemirasHalacha(shemirasYomi.getEnd()) - : " - " + formatShemirasKlalRef(shemirasYomi.getEnd()))); - } - return formatShemirasSection(shemirasYomi.getSection()) + " " + formatShemirasSectionRef(shemirasYomi.getStart()) - + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" : formatShemirasSectionRangeEnd(shemirasYomi.getStart(), shemirasYomi.getEnd())); - } - if ("x".equals(shemirasYomi.getSection())) { - return formatShemirasEnglishKlalRef(shemirasYomi.getStart()) + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" - : (sameShemirasKlal(shemirasYomi.getStart(), shemirasYomi.getEnd()) ? "-" + shemirasHalachaEnglish(shemirasYomi.getEnd()) - : " - " + formatShemirasEnglishKlalRef(shemirasYomi.getEnd()))); + String section = formatShemirasSection(shemirasYomi.getSection()); + return "שמירת הלשון, חלק " + formatHebrewNumber(shemirasYomi.getBook()) + + (section.length() == 0 ? ", " : ", " + section + ", ") + + formatShemirasSectionRef(shemirasYomi.getStart()) + + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" + : formatShemirasSectionRangeEnd(shemirasYomi.getStart(), shemirasYomi.getEnd())); } - return "Shemirat HaLashon, " + shemirasYomi.getSection() + " " + shemirasYomi.getStart() - + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" : "-" + shemirasYomi.getEnd()); + String section = formatShemirasEnglishSection(shemirasYomi.getSection()); + return "Shemirat HaLashon, Part " + shemirasYomi.getBook() + + (section.length() == 0 ? ", " : ", " + section + ", ") + + formatShemirasEnglishSectionRef(shemirasYomi.getStart()) + + (shemirasYomi.getStart().equals(shemirasYomi.getEnd()) ? "" + : formatShemirasEnglishSectionRangeEnd(shemirasYomi.getStart(), shemirasYomi.getEnd())); } private String formatKitzurRef(String ref) { @@ -987,12 +985,34 @@ private String formatRambamChapterPart(String chapter) { private String formatShemirasKlalRef(String ref) { String[] parts = ref.split("\\."); - return "כלל " + formatHebrewNumber(Integer.parseInt(parts[0])) + " " + (parts.length > 1 ? formatPlainHebrewToken(parts[1]) : ""); + return "פרק " + formatHebrewNumber(Integer.parseInt(parts[0])) + (parts.length > 1 ? " הלכה " + formatPlainHebrewToken(parts[1]) : ""); } private String formatShemirasEnglishKlalRef(String ref) { String[] parts = ref.split("\\."); - return "Klal " + parts[0] + " Halacha " + (parts.length > 1 ? parts[1] : ""); + return "Perek " + parts[0] + (parts.length > 1 ? " Halacha " + parts[1] : ""); + } + + private String formatShemirasEnglishSection(String section) { + if ("Hakdamah".equals(section)) { + return "Hakdamah"; + } + if ("Shar Hazechira".equals(section)) { + return "Shaar HaZechirah"; + } + if ("Shar Hatvuna".equals(section)) { + return "Shaar HaTevunah"; + } + if ("Shar Hatorah".equals(section)) { + return "Shaar HaTorah"; + } + if ("Chasimas Hasefer".equals(section)) { + return "Chasima"; + } + if ("x".equals(section)) { + return ""; + } + return section; } private String formatShemirasSection(String section) { @@ -1009,7 +1029,10 @@ private String formatShemirasSection(String section) { return "שער התורה"; } if ("Chasimas Hasefer".equals(section)) { - return "חתימת הספר"; + return "חתימה"; + } + if ("x".equals(section)) { + return ""; } return section; } @@ -1021,6 +1044,13 @@ private String formatShemirasSectionRef(String ref) { return formatPlainHebrewToken(ref); } + private String formatShemirasEnglishSectionRef(String ref) { + if (ref.indexOf('.') >= 0) { + return formatShemirasEnglishKlalRef(ref); + } + return ref; + } + private String formatShemirasSectionRangeEnd(String start, String end) { if (start.indexOf('.') >= 0 && end.indexOf('.') >= 0) { return sameShemirasKlal(start, end) ? "-" + shemirasHalacha(end) : " - " + formatShemirasKlalRef(end); @@ -1028,6 +1058,13 @@ private String formatShemirasSectionRangeEnd(String start, String end) { return "-" + formatPlainHebrewToken(end); } + private String formatShemirasEnglishSectionRangeEnd(String start, String end) { + if (start.indexOf('.') >= 0 && end.indexOf('.') >= 0) { + return sameShemirasKlal(start, end) ? "-" + shemirasHalachaEnglish(end) : " - " + formatShemirasEnglishKlalRef(end); + } + return "-" + end; + } + private boolean sameShemirasKlal(String start, String end) { return start.split("\\.")[0].equals(end.split("\\.")[0]); } diff --git a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java index 0231db53..7c51ee51 100644 --- a/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java +++ b/src/test/java/com/kosherjava/zmanim/hebrewcalendar/LimudYomiCalculatorTest.java @@ -111,10 +111,10 @@ public void testKitzurShulchanAruchYomi() { public void testShemirasHaLashonYomi() { JewishCalendar calendar = new JewishCalendar(LocalDate.of(2024, 6, 26)); Assert.assertEquals( - "Klal 9 Halacha 8-10", + "Shemirat HaLashon, Part 2, Perek 9 Halacha 8-10", formatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); Assert.assertEquals( - "כלל ט׳ ח-י", + "שמירת הלשון, חלק ב׳, פרק ט׳ הלכה ח-י", hebrewFormatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); } @@ -122,10 +122,21 @@ public void testShemirasHaLashonYomi() { public void testShemirasHaLashonSectionYomi() { JewishCalendar calendar = new JewishCalendar(LocalDate.of(2024, 10, 3)); Assert.assertEquals( - "Shemirat HaLashon, Hakdamah 1-2", + "Shemirat HaLashon, Part 1, Hakdamah, 1-2", formatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); Assert.assertEquals( - "הקדמה א-ב", + "שמירת הלשון, חלק א׳, הקדמה, א-ב", + hebrewFormatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); + } + + @Test + public void testShemirasHaLashonShaarYomi() { + JewishCalendar calendar = new JewishCalendar(LocalDate.of(2024, 10, 13)); + Assert.assertEquals( + "Shemirat HaLashon, Part 1, Shaar HaZechirah, Perek 1 Halacha 1-4", + formatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); + Assert.assertEquals( + "שמירת הלשון, חלק א׳, שער הזכירה, פרק א׳ הלכה א-ד", hebrewFormatter.formatShemirasHaLashonYomi(calendar.getShemirasHaLashonYomi())); } }