pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

Durations not exhibiting expected mathematical properties

Open jacobg opened this issue 5 years ago • 0 comments

Examples:

>>> pendulum.datetime(2020, 12, 1) + pendulum.parse('P1M')
DateTime(2021, 1, 1, 0, 0, 0, tzinfo=Timezone('UTC'))

>>> pendulum.datetime(2021, 1, 1) - pendulum.datetime(2020, 12, 1) == pendulum.parse('P1M')
False

>>> pendulum.datetime(2020, 12, 31) - pendulum.datetime(2020, 12, 1) == pendulum.parse('P1M')
True

>>> pendulum.datetime(2020, 12, 31) - pendulum.datetime(2020, 12, 1) == pendulum.parse('P30D')
True

>>> pendulum.parse('P1M') == pendulum.parse('P30D')
True

>>> pendulum.parse('P1M') == pendulum.parse('P31D')
False

These functions were invoked on Jan 1 2021. Both December and January have 31 days. There seems to be a one-off here.

jacobg avatar Jan 01 '21 14:01 jacobg