Skip to content

Keep every Daf Yomi Yerushalmi daf and give the molad of Teves 3761 - #297

Merged
KosherJava merged 1 commit into
KosherJava:masterfrom
dickermoshe:fix-yerushalmi-and-early-molad
Oct 23, 2026
Merged

KosherJava merged 1 commit into
KosherJava:masterfrom
dickermoshe:fix-yerushalmi-and-early-molad

Conversation

@dickermoshe

Copy link
Copy Markdown
Contributor

The bugs

Daf Yomi Yerushalmi skips a daf. When a cycle is extended for Yom Kippur or Tisha B'Av, a skip day that falls on the first day of the extension is not counted, so the cycle ends a day early and loses its last daf. The first such cycle ends in 2172. On 7 August 2172 getDafYomiYerushalmi returns Berachos 1 instead of Niddah 13, so Niddah 13 is never learned. Later dates are off too: 2 November 2203 gives Shabbos 75 instead of 74. The cycle ending in August 2480 loses a daf the same way.

The molad of Teves 3761 throws. getMolad() and getMoladAsInstant() throw "Dates in the BC era are not supported" for 18 to 29 Teves 3761, the first dates a JewishDate accepts. That molad is on Tuesday 12 December of year 0, before 1 January 0001.

Why

YerushalmiYomiCalculator.isBetween counts Yom Kippur and Tisha B'Av after the start of the range, not on it. getNextCycleStart extends a cycle by counting skip days from the day after the previous end, so a skip day on that first day is missed. getDafYomiYerushalmi counts skip days from the start of the cycle in the same way.

JewishDate(long molad) goes through setAbsDate, which rejects any date before 1 January 0001. Letting the date through is not enough on its own, because three calculations assume a positive absolute date.

  • gregorianDateToAbsDate counts leap days with /, which rounds toward zero. For year 0 that misses its leap day, so every date in year 0 comes out a day late, and absDateToDate returns the day before.
  • absDateToDate starts its search at absDate / 366.
  • The day of the week is Math.abs(absDate % 7) + 1, which gives Friday for 12 December 0000 instead of Tuesday.

The fix

  • isBetween includes the start date. The Javadoc says why.
  • setAbsDate accepts any absolute date. The check for dates before 1 January 0001 moved to setGregorianDate and minusDays, the two places a caller's date can fall before it, so they throw as before. plusDays only moves forward and clone copies an existing date.
  • gregorianDateToAbsDate and absDateToDate use Math.floorDiv, and the day of the week uses Math.floorMod. For every date from 1 January 0001 on, the results are the same as before.

Testing

  • UT_YerushalmiTest.testCycleExtendedForTishaBav checks 6 to 8 August 2172. It fails without the fix ("2172-08-07 expected:<38> but was:<0>") and passes with it.
  • UT_YerushalmiTest.testCycleWithTishaBavBeforeItsLastDaf checks 14 to 17 August 2480. It fails without the fix and passes with it.
  • UT_JewishDateNavigation.moladInGregorianYear0 checks the date, day of the week, hours, minutes and chalakim of the molad of Teves 3761. It throws without the fix and passes with it.
  • All 135 tests pass.
  • The same Yerushalmi rule in a port of this library was checked on every day from 2 February 1980 to the end of 9999: every cycle has all 1,554 dafim in order, and only Yom Kippur and Tisha B'Av have none. Up to 7 August 2172 it matches @hebcal/learning on every day.

A Yom Kippur or Tisha B'Av on the first day of a cycle extension was not
counted, so the Yerushalmi cycle ending in 2172 lost Niddah 13. isBetween
now includes the start date.

The molad of Teves 3761 is on 12 December 0000, which setAbsDate rejected.
setAbsDate now accepts it, and setGregorianDate and minusDays keep the check.
gregorianDateToAbsDate, absDateToDate and the day of the week use floor
division so year 0 gets its leap day and the right weekday.
@KosherJava
KosherJava merged commit 6d9026d into KosherJava:master Oct 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants