There's an issue with month subtraction. Repro steps:
import Date exposing (fromTime)
import Date.Extra.Duration exposing (Duration(..), add)
today = fromTime 1499529702655
add Month -7 today -- results in Dec 08 2016, which is right
add Month -19 today -- results in Dec 08 2014, which is one year to the past wrong
add Month -20 today -- results in Nov 08 2015, which is right again
Seems that problem is with the yearOffset in the addMonth function, but I'm not sure. I'll probably do some work on this.
Update
Further investigation showed that the root problem is in the Internal.daysFromCivil. When targetMonthInt equals zero resulting year is reduced by one (which is logical and right behavior). But when newMonthInt is simultaneously less than zero (in case of subtracting 12 + currentMonthNumber months or more) it leads to additional year subtraction from yearOffset.
There's an issue with month subtraction. Repro steps:
Seems that problem is with theyearOffset
in theaddMonth
function, but I'm not sure. I'll probably do some work on this.Update
Further investigation showed that the root problem is in the
Internal.daysFromCivil
. WhentargetMonthInt
equals zero resulting year is reduced by one (which is logical and right behavior). But whennewMonthInt
is simultaneously less than zero (in case of subtracting12 + currentMonthNumber
months or more) it leads to additional year subtraction fromyearOffset
.I'll be making a PR now.