Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,266 @@ 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())
+ ": " + formatMishnaNumber(mishnaYomi.getStartMishna()) : mishnaYomi.getMasechtaTransliterated() + " "
+ mishnaYomi.getStartChapter() + ":" + mishnaYomi.getStartMishna());
if (mishnaYomi.getStartMasechtaNumber() == mishnaYomi.getEndMasechtaNumber()
&& mishnaYomi.getStartChapter() == mishnaYomi.getEndChapter()) {
return start + "-" + (hebrewFormat ? formatMishnaNumber(mishnaYomi.getEndMishna()) : mishnaYomi.getEndMishna());
}
return start + "-" + (hebrewFormat ? mishnaYomi.getEndMasechta() + " " + formatHebrewNumber(mishnaYomi.getEndChapter())
+ ": " + formatMishnaNumber(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) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < rambamYomi.getReadingCount(); i++) {
if (i > 0) {
sb.append(", ");
}
String start = rambamYomi.getStartChapter(i);
String end = rambamYomi.getEndChapter(i);
if (hebrewFormat) {
sb.append(formatRambamHebrewName(rambamYomi.getBookNumber(i)));
sb.append(start.equals(end) ? " פרק " : " פרקים ");
sb.append(formatRambamChapter(start));
if (!start.equals(end)) {
sb.append("-").append(formatRambamChapter(end));
}
} else {
sb.append(rambamYomi.getName(i)).append(" ").append(start);
if (!start.equals(end)) {
sb.append("-").append(end);
}
}
}
return sb.toString();
}

/**
* 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) {
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())));
}
return "Shemirat HaLashon, " + shemirasYomi.getSection() + " " + 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 formatRambamHebrewName(int bookNumber) {
String name = LimudYomiData.RAMBAM_NAMES_HEBREW[bookNumber];
if (bookNumber < 4 || "סדר התפילה".equals(name)) {
return name;
}
return "הלכות " + name;
}

private String formatRambamChapter(String chapter) {
String[] range = chapter.split("-");
if (range.length == 2) {
return formatRambamChapterPart(range[0]) + "-" + formatRambamChapterPart(range[1]);
}
return formatRambamChapterPart(chapter);
}

private String formatRambamChapterPart(String chapter) {
String[] parts = chapter.split(":");
if (parts.length == 2) {
return formatPlainHebrewNumber(Integer.parseInt(parts[0])) + ":" + formatPlainHebrewNumber(Integer.parseInt(parts[1]));
}
return formatPlainHebrewNumber(Integer.parseInt(chapter));
}

private String formatShemirasKlalRef(String ref) {
String[] parts = ref.split("\\.");
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 "הקדמה";
}
if ("Shar Hazechira".equals(section)) {
return "שער הזכירה";
}
if ("Shar Hatvuna".equals(section)) {
return "שער התבונה";
}
if ("Shar Hatorah".equals(section)) {
return "שער התורה";
}
if ("Chasimas Hasefer".equals(section)) {
return "חתימת הספר";
}
return section;
}

private String formatShemirasSectionRef(String ref) {
if (ref.indexOf('.') >= 0) {
return formatShemirasKlalRef(ref);
}
return formatPlainHebrewToken(ref);
}

private String formatShemirasSectionRangeEnd(String start, String end) {
if (start.indexOf('.') >= 0 && end.indexOf('.') >= 0) {
return sameShemirasKlal(start, end) ? "-" + shemirasHalacha(end) : " - " + formatShemirasKlalRef(end);
}
return "-" + formatPlainHebrewToken(end);
}

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 shemirasHalachaEnglish(String ref) {
String[] parts = ref.split("\\.");
return parts.length > 1 ? parts[1] : "";
}

private String formatHebrewToken(String token) {
if ("E".equals(token)) {
return "סוף";
}
if ("Shmita".equals(token)) {
return "שמיטה";
}
if ("Klalim".equals(token)) {
return "כללים";
}
try {
return formatHebrewNumber(Integer.parseInt(token));
} catch (NumberFormatException e) {
return token;
}
}

private String formatPlainHebrewToken(String token) {
if ("E".equals(token)) {
return "סוף";
}
if ("Shmita".equals(token)) {
return "שמיטה";
}
if ("Klalim".equals(token)) {
return "כללים";
}
try {
return formatPlainHebrewNumber(Integer.parseInt(token));
} catch (NumberFormatException e) {
return token;
}
}

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.
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,62 @@ public Daf getDafYomiBavli() {
public Daf getDafYomiYerushalmi() {
return YerushalmiYomiCalculator.getDafYomiYerushalmi(this);
}

/**
* Returns the <em>Mishna Yomi</em> for the date that the calendar is set to.
* @return the Mishna Yomi as a {@link MishnaYomi}
*/
public MishnaYomi getMishnaYomi() {
return MishnaYomiCalculator.getMishnaYomi(this);
}

/**
* Returns the one chapter <em>Rambam Yomi</em> for the date that the calendar is set to.
* @return the Rambam Yomi as a {@link RambamYomi}
*/
public RambamYomi getRambamYomi() {
return RambamYomiCalculator.getRambamYomi(this);
}

/**
* Returns the three chapter <em>Rambam Yomi</em> for the date that the calendar is set to.
* @return the Rambam Yomi as a {@link RambamYomi}
*/
public RambamYomi getRambamYomi3Chapters() {
return RambamYomiCalculator.getRambamYomi3Chapters(this);
}

/**
* Returns the daily Tehillim for the date that the calendar is set to.
* @return the daily Tehillim as a {@link TehillimYomi}
*/
public TehillimYomi getDailyTehillim() {
return TehillimYomiCalculator.getDailyTehillim(this);
}

/**
* Returns the <em>Tanach Yomi</em> for the date that the calendar is set to.
* @return the Tanach Yomi as a {@link TanachYomi}, or null on days without a reading
*/
public TanachYomi getTanachYomi() {
return TanachYomiCalculator.getTanachYomi(this);
}

/**
* Returns the <em>Kitzur Shulchan Aruch Yomi</em> for the date that the calendar is set to.
* @return the Kitzur Shulchan Aruch Yomi as a {@link KitzurShulchanAruchYomi}, or null on days without a reading
*/
public KitzurShulchanAruchYomi getKitzurShulchanAruchYomi() {
return KitzurShulchanAruchYomiCalculator.getKitzurShulchanAruchYomi(this);
}

/**
* Returns the <em>Shemiras HaLashon Yomi</em> for the date that the calendar is set to.
* @return the Shemiras HaLashon Yomi as a {@link ShemirasHaLashonYomi}
*/
public ShemirasHaLashonYomi getShemirasHaLashonYomi() {
return ShemirasHaLashonYomiCalculator.getShemirasHaLashonYomi(this);
}

/**
* Returns the elapsed days since <em>Tekufas Tishrei</em>. This uses <em>Tekufas Shmuel</em> (identical to the <a href=
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Zmanim Java API
* Copyright © 2026 Eliyahu Hershfeld
*
* 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;

/** An object representing a Kitzur Shulchan Aruch Yomi reading. */
public class KitzurShulchanAruchYomi {
private final String start;
private final String end;

public KitzurShulchanAruchYomi(String start, String end) {
this.start = start;
this.end = end;
}

public String getStart() {
return start;
}

public String getEnd() {
return end;
}
}
Loading