timex
timex copied to clipboard
Inconsistency in `shift/2` with months, years
Steps to reproduce
> start_datetime = ~U[2024-02-29 09:00:00Z]
~U[2025-02-28 09:00:00Z]
> Timex.shift(start_datetime , months: 12)
~U[2025-03-01 09:00:00Z]
> Timex.shift(start_datetime , months: 12) == Timex.shift(start_datetime , years: 1)
false
Description of issue
- What are the expected results?
The results of shifting 12 months and 1 year are the same.
In a non-leap year, a person with a birthday on 2/29 has a birthday party on 2/28.
But it's 3/1 in Timex.
https://github.com/bitwalker/timex/blob/22230a00af1c4fc36fd25c3935f5eacafc19df4f/lib/datetime/datetime.ex#L566
But it's a breaking change... I can just use my own fork of Timex.