Skip to content

last day of the month is wrong?? #1167

@hawkEye-01

Description

@hawkEye-01

From documentation, it seems to correctly get last day of the month..
How does it handle months with different numbers of days? Notice that adding one month will never cross the month boundary.

>>> date(2003,1,27)+relativedelta(months=+1)
datetime.date(2003, 2, 27)
>>> date(2003,1,31)+relativedelta(months=+1)
datetime.date(2003, 2, 28)
>>> date(2003,1,31)+relativedelta(months=+2)
datetime.date(2003, 3, 31)

I tried,

from datetime import date
print(date(2021, 6, 30) + relativedelta(months=-1))

which gives 2021-05-30. i should have been 2021-05-31.

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