Open obecker opened 2 years ago
I might also be useful to configure a github action that execute all tests after this issue has been fixed. See https://docs.github.com/en/actions/quickstart and https://docs.github.com/en/actions/guides/building-and-testing-java-with-maven
Hey @obecker - You're 100% right. I'm about to be doing some PR work on this library (merges and such) to get caught up. If you're interested in contributing a patch that fixes this, I'd love to include it! It would be great to have more stable tests.
When trying to contribute to this project, I was very surprised to see that a lot of unit tests are failing.
After digging into the code I realized that this results most probably from using current dates in the tests. However, this is a problem because a year in reality has a different amount of millis depending on the current date, but a year in
prettytime
has always 31556925960 millis (about 365,242 days). So current date minus 1 year will format as "one year ago" in a leap year (i.e. the duration contains the leap day), but as "12 months ago" in all other years.To fix this all tests should be based on defined dates, so they will produces the same results no matter when the tests are executed.
See the adjusted test in https://github.com/ocpsoft/prettytime/pull/229 as an example