You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 #229 as an example
The text was updated successfully, but these errors were encountered: