-
Notifications
You must be signed in to change notification settings - Fork 263
More documentation for min_months_from_inner #7746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+30
−4
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
459c94a
More documentation for min_months_from_inner
Manishearth a311bcb
Update components/calendar/src/calendar_arithmetic.rs
Manishearth 68b22b7
Update components/calendar/src/calendar_arithmetic.rs
Manishearth c9fb1c5
Update components/calendar/src/calendar_arithmetic.rs
Manishearth 157cedb
Update components/calendar/src/cal/hebrew.rs
Manishearth 72976d7
Update components/calendar/src/cal/hebrew.rs
Manishearth c209736
Update components/calendar/src/cal/hebrew.rs
Manishearth 1374201
approx
Manishearth d7dfacb
Comment on EAT about leap year cadence
Manishearth 73673f0
fractions
Manishearth 8aade84
Update components/calendar/src/cal/east_asian_traditional.rs
Manishearth 132791d
fmt
Manishearth f004be7
undo chinese
Manishearth 136d206
undo undo
Manishearth f29a76e
remove documented invariant
Manishearth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,30 @@ impl DateFieldsResolver for Hebrew { | |
|
|
||
| #[inline] | ||
| fn min_months_from_inner(_start: HebrewYear, years: i64) -> i64 { | ||
| // There are 7 leap years in every 19-year Metonic cycle. | ||
| // The Hebrew Metonic cycle is 7 leap years every 19 years, | ||
| // which comes out to 235 months per 19 years. | ||
| // | ||
| // We need to ensure that this is always *lower or equal to* the number of | ||
| // months in a given year span. | ||
| // | ||
| // Firstly, note that this math will produce exactly the number of months in any given cycle | ||
| // that is a multiple of 19 years. Note that we are only performing integer | ||
Manishearth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // ops here, and our SAFE_YEAR_RANGE is well within the range of allowed values | ||
| // for multiplying by 235. | ||
| // | ||
| // So we only need to verify that this math produces the right results within a single cycle. | ||
| // | ||
| // The Hebrew Metonic cycle has leap years in year 3, 6, 8, 11, 14, 17, and 19, | ||
| // i.e., leap year gaps of +3, +3, +2, +3, +3, +3, +2. | ||
|
||
| // | ||
| // 235 / 19 is 12.368 months per year, which leads to one leap month every three years plus 0.1 | ||
Manishearth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // month left over. So this is "in bounds" as long as it does not predict a leap month in 2 years | ||
Manishearth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // where the Hebrew calendar expects one in 3. | ||
| // | ||
| // The longest sequence of "three year leap months" in the Hebrew calendar | ||
| // is 4: year 9->11->14->17. In that time the error will accumulate to about 0.3, which is not | ||
Manishearth marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // enough to create a "two year leap month" in our calculation. So this calculation cannot go past | ||
| // the actual cycle of the Hebrew calendar. | ||
| 235 * years / 19 | ||
| } | ||
|
|
||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.