HebrewDateFormatter

The HebrewDateFormatter class formats a JewishDate.

The class formats Jewish dates, numbers, Daf Yomi (Bavli and Yerushalmi), the Omer, Parshas Hashavua (including the special parshiyos of Shekalim, Zachor, Parah and Hachodesh), Yomim Tovim and the Molad (experimental) in Hebrew or Latin chars, and has various settings. Sample full date output includes (using various options):

  • 21 Shevat, 5729

  • כא שבט תשכט

  • כ״א שבט ה׳תשכ״ט

  • כ״א שבט תש״פ or כ״א שבט תש״ף

  • כ׳ שבט ו׳ אלפים

Author

Eliyahu Hershfeld 2011 - 2023

See also

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
var hebrewOmerPrefix: String

The Hebrew omer prefix character. It defaults to ב producing בעומר, but can be set to ל to produce לעומר (or any other prefix).

Link copied to clipboard
var isHebrewFormat: Boolean

Returns if the formatter is set to use Hebrew formatting in the various formatting methods.

Link copied to clipboard
var isLongWeekFormat: Boolean

Setting to control if the formatDayOfWeek will use the long format such as ראשון or short such as א when formatting the day of week in Hebrew.

Link copied to clipboard

When formatting a Hebrew Year, traditionally years ending in 20, 40, 50, 80 and 90 are formatted using non-final form letters for example תש״פ for the year 5780. Setting this to true (the default is false) will use the final form letters for מנצפ״ך and will format the year 5780 as תש״ף.

Link copied to clipboard
var isUseGershGershayim: Boolean

Sets whether to use the Geresh ׳ and Gershayim ״ in formatting Hebrew dates and numbers. The default value is true and output would look like כ״א שבט תש״כ (or כ״א שבט תש״ך). When set to false, this output would display as כא שבט תשכ (or כא שבט תשך). Single digit days or month or years such as כ׳ שבט ו׳ אלפים show the use of the Geresh.

Link copied to clipboard

Returns whether the class is set to use the thousand's digit when formatting: true if set to use the thousand's digit when formatting Hebrew dates and numbers.

Link copied to clipboard
var transliteratedHolidayList: Array<String>

Returns the list of holidays transliterated into Latin chars. This is used by the formatYomTov when formatting the Yom Tov String. The default list of months uses Ashkenazi pronunciation in typical American English spelling.

Link copied to clipboard
var transliteratedMonthList: Array<String>

Returns the list of months transliterated into Latin chars. The default list of months uses Ashkenazi pronunciation in typical American English spelling. This list has a length of 14 with 3 variations for Adar - "Adar", "Adar II", "Adar I"

Link copied to clipboard

List of transliterated parshiyos using the default Ashkenazi pronunciation.  The formatParsha method uses this for transliterated parsha formatting.  This list can be overridden (for Sephardi English transliteration for example) by setting the transliteratedParshiosList.  The list includes double and special parshiyos is set as "Bereshis, Noach, Lech Lecha, Vayera, Chayei Sara, Toldos, Vayetzei, Vayishlach, Vayeshev, Miketz, Vayigash, Vayechi, Shemos, Vaera, Bo, Beshalach, Yisro, Mishpatim, Terumah, Tetzaveh, Ki Sisa, Vayakhel, Pekudei, Vayikra, Tzav, Shmini, Tazria, Metzora, Achrei Mos, Kedoshim, Emor, Behar, Bechukosai, Bamidbar, Nasso, Beha'aloscha, Sh'lach, Korach, Chukas, Balak, Pinchas, Matos, Masei, Devarim, Vaeschanan, Eikev, Re'eh, Shoftim, Ki Seitzei, Ki Savo, Nitzavim, Vayeilech, Ha'Azinu, Vezos Habracha, Vayakhel Pekudei, Tazria Metzora, Achrei Mos Kedoshim, Behar Bechukosai, Chukas Balak, Matos Masei, Nitzavim Vayeilech, Shekalim, Zachor, Parah, Hachodesh,Shuva, Shira, Hagadol, Chazon, Nachamu".

Link copied to clipboard

Returns the day of Shabbos transliterated into Latin chars. The default uses Ashkenazi pronunciation "Shabbos". This can be overwritten using the transliteratedShabbosDayOfWeek to alternate spellings such as "Shabbat" used by the formatDayOfWeek

Functions

Link copied to clipboard
fun format(jewishDate: JewishDate): String

Formats the Jewish date. If the formatter is set to Hebrew, it will format in the form, "day Month year" for example כ״א שבט תשכ״ט, and the format "21 Shevat, 5729" if not.

Link copied to clipboard
fun formatDafYomiBavli(daf: Daf): String

Formats the Daf Yomi Bavli in the format of "עירובין נ״ב" in Hebrew, or the transliterated format of "Eruvin 52".

Link copied to clipboard
fun formatDafYomiYerushalmi(daf: Daf?): String

Formats the Daf Yomi Yerushalmi in the format of "עירובין נ״ב" in Hebrew, or the transliterated format of "Eruvin 52".

Link copied to clipboard
fun formatDayOfWeek(jewishDate: JewishDate): String

Formats the day of week. If .isHebrewFormat is set, it will display in the format ראשון etc. If Hebrew formatting is not in use it will return it in the format of Sunday etc. There are various formatting options that will affect the output.

Link copied to clipboard
fun formatHebrewNumber(number: Int): String

Returns a Hebrew formatted string of a number. The method can calculate from 0 - 9999.

fun formatHebrewNumber(number: Long): String
Link copied to clipboard
fun formatMonth(jewishDate: JewishDate): String

Returns a string of the current Hebrew month such as "Tishrei". Returns a string of the current Hebrew month such as "אדר ב׳".

Link copied to clipboard
fun formatOmer(jewishCalendar: JewishCalendar): String

Returns a String of the Omer day in the form ל״ג בעומר if Hebrew Format is set, or "Omer X" or "Lag B'Omer" if not. An empty string if there is no Omer this day.

Link copied to clipboard
fun formatParsha(jewishCalendar: JewishCalendar): String?

Returns a String with the name of the current parsha(ios). If the formatter is set to format in Hebrew, returns a string of the current parsha(ios) in Hebrew for example בראשית or נצבים וילך or an empty string if there are none. If not set to Hebrew, it returns a string of the parsha(ios) transliterated into Latin chars. The default uses Ashkenazi pronunciation in typical American English spelling, for example Bereshis or Nitzavim Vayeilech or an empty string if there are none.

Link copied to clipboard
fun formatRoshChodesh(jewishCalendar: JewishCalendar): String

Formats a day as Rosh Chodesh in the format of in the format of ראש חודש שבט or Rosh Chodesh Shevat. If it is not Rosh Chodesh, an empty String will be returned.

Link copied to clipboard
fun formatSpecialParsha(jewishCalendar: JewishCalendar): String?

Returns a String with the name of the current special parsha of Shekalim, Zachor, Parah or Hachodesh or an empty String for a non-special parsha. If the formatter is set to format in Hebrew, it returns a string of the current special parsha in Hebrew, for example שקלים, זכור, פרה or החדש. An empty string if the date is not a special parsha. If not set to Hebrew, it returns a string of the special parsha transliterated into Latin chars. The default uses Ashkenazi pronunciation in typical American English spelling Shekalim, Zachor, Parah or Hachodesh.

Link copied to clipboard
fun formatYomTov(jewishCalendar: JewishCalendar): String

Formats the Yom Tov (holiday) in Hebrew or transliterated Latin characters.

Link copied to clipboard
fun getFormattedKviah(jewishYear: Int): String

Returns the kviah in the traditional 3 letter Hebrew format where the first letter represents the day of week of Rosh Hashana, the second letter represents the lengths of Cheshvan and Kislev (Shelaimim , Kesidran or Chaserim) and the 3rd letter represents the day of week of Pesach. For example 5729 (1969) would return בשה (Rosh Hashana on Monday, Shelaimim, and Pesach on Thursday), while 5771 (2011) would return השג (Rosh Hashana on Thursday, Shelaimim, and Pesach on Tuesday).

fun getFormattedKviah(jewishYear: Long): String