Repository navigation
Fix getLocalDate() for dates before January 1, 0001 - #308
Open
dickermoshe wants to merge 1 commit into
Open
dickermoshe wants to merge 1 commit into
dickermoshe wants to merge 1 commit into
Conversation
absDateToDate guessed the year with floorDiv(absDate, 366) and searched forward. For a negative absDate that guess can be later than the correct year, so LocalDate.of threw for a JewishDate built from an early molad. Divide by 365 when absDate is not positive. Fixes KosherJava#307
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #307.
absDateToDateguessed the year withMath.floorDiv(absDate, 366)and searched forward. For a negativeabsDate, dividing by 366 rounds toward zero, so the guess can be later than the correct year. The forward search then can't reach it, andLocalDate.ofthrows. AJewishDatebuilt withnew JewishDate(long molad)from an early molad reaches this throughgetLocalDate().This divides by 365 when
absDateis not positive. That guess is never after the correct year, so the forward search finds it. Positive dates use the same guess as before.Tests
The new
UT_GregorianDateConversionchecks the following:Invalid value for DayOfMonth (valid values 1 - 28/31): -129before this change and now returns August 24, 762 BCE (-0761-08-24)java.timeThree of the new tests fail without the fix. The full suite passes with it.