sindresorhus/refined-github

`repo-age` date calculation inconsistent with GitHub's calculation #4620

shinenelson posted onGitHub

Description

Disclaimer : I am not sure whether this is a bug that we should be resolving on our end. That is why I am proposing this as an enhancement.

GitHub probably uses only the year to calculate the age of a commit. However, twas ( required in repo-age ) returns a relative date based on the full date of the commit to calculate the age of the repository.

This makes the reporting inconsistent if the first commit in the repository was on a date ( month and date ) that is in the future of the current year.

Screenshot

image

Example URL

https://github.com/daenney/monitoring


I am not sure I am understanding the issue. The first date of the commit was when?

posted by yakov116 over 3 years ago

Nice catch!

<img width="358" alt="Screen Shot 1" src="https://user-images.githubusercontent.com/1402241/127533111-fe49f8a1-73e4-407b-ad5b-263000babe8b.png">

Maybe our twas module truncates the number while GitHub rounds.

Maybe we have to suggest to twas to match GitHub’s behavior (which I assume rounds numbers at .5 exactly). We tried using GitHub’s date element but it wasn't reliable/fast enough last time we tried it.

posted by fregante over 3 years ago

Maybe we have to suggest to twas to match GitHub’s behavior

I prefer twas' method. It makes more sense when the value is rounded / truncated.

In my head, it is not yet 5 years since October 23, 2016. It will be 5 years on October 23, 2021. Should I go suggest this to GitHub now?

twas is a generic module and not related to GitHub; so would it change its behavior even if we suggested to change it?

posted by shinenelson over 3 years ago

I doubt GitHub will adjust that and honestly 4 years 11 months should not be rounded to 4 years.

not related to GitHub; so would it change its behavior even if we suggested to change it?

The reason to change is not to match GitHub, but to implement a rounding behavior. GitHub is just one that does it right, but is otherwise unrelated.

posted by fregante over 3 years ago

Feel free to send a PR to twas. I had already opened a PR to add a failing test, but this is a relatively easy change to actually fix https://github.com/vutran/twas/pull/9

posted by fregante over 3 years ago

Fund this Issue

$0.00
Funded

Pull requests