Skip to content

testNextMonth fails on February 29th #282

Open
@FelixSchwarz

Description

@FelixSchwarz

testNextMonth fails on February 29th - it returns a date two years later instead of one (e.g. 2022-02-28 instead of 2021-02-28 with a base date of 2020-02-29).

This test reproduces the issue:

def testNextMonthLeapYear(self):
    s = datetime.datetime(2020, 2, 29, self.hr, self.mn, self.sec)
    t = self.cal.inc(s, year=1)
    start = s.timetuple()
    target = t.timetuple()

    self.assertEqual(_tr(self.cal.parse('next February 28', start)),
                     _tr((target, pdtContext(pdtContext.ACU_MONTH | pdtContext.ACU_DAY))))

Output

AssertionError: Tuples differ: ((2022, 2, 28, 8, 21, 0, 0, 0, 0), pdtContext([47 chars]DAY)) != ((2021, 2, 28, 8, 21, 0, 0, 0, 0), pdtContext([47 chars]DAY))

First differing element 0:
(2022, 2, 28, 8, 21, 0, 0, 0, 0)
(2021, 2, 28, 8, 21, 0, 0, 0, 0)

- ((2022, 2, 28, 8, 21, 0, 0, 0, 0),
?        ---

+ ((2021, 2, 28, 8, 21, 0, 0, 0, 0),
?      +++

   pdtContext(accuracy=pdtContext.ACU_MONTH | pdtContext.ACU_DAY))

Initially reported by @hroncok in https://bugzilla.redhat.com/show_bug.cgi?id=1808449

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions