Skip to content

fix(core): Account age inaccuracy due to leap years#499

Closed
spenserblack wants to merge 2 commits intolowlighter:masterfrom
spenserblack:bugfix/date-diff
Closed

fix(core): Account age inaccuracy due to leap years#499
spenserblack wants to merge 2 commits intolowlighter:masterfrom
spenserblack:bugfix/date-diff

Conversation

@spenserblack
Copy link
Contributor

By converting the diff to a date, the date since 1970 is calculated. The
year of that date minus 1970 would then equal the number of years that
have passed, taking leap years into account.

Resolves #497


As a side note, I wanted to write tests for this, but making all the computed values of the core plugin testable would require a lot of refactoring, it seems.

By converting the diff to a date, the date since 1970 is calculated. The
year of that date minus 1970 would then equal the number of years that
have passed, taking leap years into account.
@spenserblack
Copy link
Contributor Author

Closing to avoid spamming vercel

@lowlighter
Copy link
Owner

Thanks for fixing this!
Looks good to me 👍


However I think the diff value may break the progress tracking of the "Member" achievement as it expects a float number of years:

const value = computed.registered.diff

(This way it makes it progress a little day-by-day instead of waiting a whole year)

But I'm not sure what's the best way to solve this 🤔
Maybe something along diff: years + months/11 + days/(lastMonthNumberOfDays) ?


As a side note, I wanted to write tests for this, but making all the computed values of the core plugin testable would require a lot of refactoring, it seems.

Yeah that's ok. Testing metrics is quite hard because there are so many edges cases, and mocking apis and data is really tedious x)

@spenserblack
Copy link
Contributor Author

However I think the diff value may break the progress tracking of the "Member" achievement as it expects a float number of years:

Oh, I see. I partially addressed the breakage in #501, but I failed to make it increase in daily with this method.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Account age calculation is slightly inaccurate

2 participants