Repository navigation
fix: use calendar-aware year calculation in renew modal to prevent infinite loop - #1125
Closed
tenderdeve wants to merge 1 commit into
Closed
tenderdeve wants to merge 1 commit into
tenderdeve wants to merge 1 commit into
Conversation
…finite loop The year input in the renew modal caused an infinite increment for large values (e.g. 1600) because of a feedback loop between a leap-day-ignorant seconds-to-years conversion and a leap-day-aware years-to-seconds conversion. Replace the naive floor division with calendar-aware date diff arithmetic so the roundtrip is stable. Fixes ensdomains#1076
|
Member
|
Closing in favour of #1130, which is a re-push of this exact commit from a maintainer branch so CI can run for first-time contributors. Original commit authorship preserved via cherry-pick, so you remain the commit author on the re-submission. Thanks again for the diagnosis and fix, @tenderdeve. |
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.



Summary
Math.floor(seconds / ONE_YEAR)whereONE_YEAR = 365 * 24 * 3600) and a leap-day-aware years-to-seconds conversion (Date.setFullYear()). For large values, the leap day accumulation caused the year count to keep increasing on each render.secondsToYearsfloor division withcalculateDatesDiff(startDate, endDate).diff.years, which uses calendar-aware date arithmetic consistent with the years-to-seconds path, creating a stable roundtrip.File:
src/components/@molecules/DateSelection/DateSelection.tsxFixes #1076
Test plan