tbillington / kondo

Cleans dependencies and build artifacts from your projects.
MIT License
1.8k stars 52 forks source link

72 years ago #99

Open faassen opened 1 year ago

faassen commented 1 year ago

I am getting time information like "72 years ago", which is both unlikely and most importantly, not actually true. :)

For example, for a node_modules directory with the date Jan 19 2018 I'm getting "72 years ago". I can't explain it through a confusion with months; that's more like 67 months ago.

For items months ago, I am getting plausible time periods.

I'm on Fedora 38. I installed the tool through cargo install after cloning from git.

faassen commented 1 year ago

Looking through the source it looks like:

https://github.com/tbillington/kondo/blob/cc5478fea9e89aeb2467cc93057bd99116532299/kondo-lib/src/lib.rs#L280

is dividing by months instead of years. I think the discrepancy between 72 and 67 is due to division by a hardcoded number where a month is 4 weeks and thus 28 days, versus calculating the actual duration. The year appears to consist of 336 days.

tbillington commented 1 year ago

Thanks for the report :) I would be impressed by a 72 year old project.

I've fixed the incorrect unit for now. The math is still not perfect but hopefully this also brings it closer.