pendulum
pendulum copied to clipboard
Durations not exhibiting expected mathematical properties
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.