pendulum
pendulum copied to clipboard
Month subtraction does not account for years passed
- [X] I am on the latest Pendulum version.
- [ ] I have searched the issues of this repo and believe that this is not a duplicate.
- OS version and name: Microsoft Windows 10 64bit
- Pendulum version: 2.1.2
Issue
Month subtraction works incorrectly. It only subtracts the month value of the second variable from the first variable, and doesn't account for the year.
>>> y=pendulum.datetime(2022,5,1)
>>> x=pendulum.datetime(2020,1,1)
>>> (y-x).months
4
Can this be assigned to me?
@sdispater
This appears to be as documented: https://github.com/sdispater/pendulum/blame/master/docs/docs/duration.md#L80
You should be using method (y-x).in_months() if you're trying to get duration in truncated months.