Skip to content

February months diff value is returning wrong value #402

Open

Description

@yardensachs

When diffing date between 2019-08-30 and 2020-02-29 - the months counter will show "5" instead of "6".

Reproduce:

import datetime
import pendulum
d1 = pendulum.instance(datetime.datetime(2019, 8, 30))
d2 = d1.add(months=6)
d1.diff(d2).months
->
5

Or with less lines:

d1 = datetime.datetime(2019, 8, 30)
pendulum.instance(d1).diff(pendulum.instance(d1).add(months=6)).months
->
5

I think the problem is in precise_diff function.
https://github.com/sdispater/pendulum/blob/master/pendulum/_extensions/helpers.py#L185

Activity

  1. yardensachs commented on Nov 10, 2019

    @yardensachs
    Author

    Any news on this issue?
    @sdispater

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions