carbon icon indicating copy to clipboard operation
carbon copied to clipboard

DiffInMonths does not consider the positive and negative of the time period

Open almas1992 opened this issue 2 years ago • 1 comments

Hello,

I encountered an issue with the following code:

carbon.Parse("2022-08-08 22:55:15").DiffInMonths(carbon.Parse("2022-09-18 22:55:19"))
carbon.Parse("2022-09-18 22:55:19").DiffInMonths(carbon.Parse("2022-08-08 22:55:15"))

golang version: sgo1.19.1 darwin/arm64

carbon version: v2.1.9

time zone: such as Japan

I expected to get:

1
-1

But I actually get:

1
-2

Thanks!

almas1992 avatar Sep 19 '22 02:09 almas1992

Thanks, it will be fixed in the next version.

gouguoyin avatar Sep 21 '22 03:09 gouguoyin

It has been fixed in 1.7.0 or 2.2.0

gouguoyin avatar Oct 27 '22 02:10 gouguoyin