Problem with date difference calculation

This is here on meta. First post dated Aug 25, next post, “2 months later” dated today. This is a PM. First post in thread also not 2 months ago.

1 Like

This was a recent change - the “x days/months/years” later used to round down, now it rounds up. Perhaps is should just “round”, instead of using floor or ceil.

https://github.com/discourse/discourse/commit/451340d0583c009d2bf0fbdf7c40fc9a01b3b1cd

cc @codinghorror @eviltrout

5 Likes

Would that even be 1.5 @eviltrout?

OH! I guess this is the end of September, which is > 1 month.

No, but since it does ceil > 1 month = 2 months. Seems like you want round.

Hmm the intent was for 1.0 - 1.499 to be “1 month” and 1.5 - 1.999 to be “2 months” @eviltrout.

3 Likes

I changed it to use round.

https://github.com/discourse/discourse/commit/c7aa354ee88ecd99cd9f42baa1aaae813776285d

10 Likes