monthly recur fix

This commit is contained in:
Erik Winter 2021-02-03 10:51:10 +01:00
parent 2ea3639505
commit d3cc6f4206
2 changed files with 25 additions and 1 deletions

View File

@ -260,7 +260,18 @@ func (enm EveryNMonths) RecursOn(date Date) bool {
return false return false
} }
return enm.Start.Day() == date.Day() tDate := enm.Start
for {
if tDate.Equal(date) {
return true
}
if tDate.After(date) {
return false
}
tYear, tMonth, tDay := tDate.Time().Date()
tDate = NewDate(tYear, int(tMonth)+enm.N, tDay)
}
} }
func (enm EveryNMonths) String() string { func (enm EveryNMonths) String() string {

View File

@ -338,6 +338,19 @@ func TestEveryNMonths(t *testing.T) {
{ {
name: "one month", name: "one month",
date: task.NewDate(2021, 3, 3), date: task.NewDate(2021, 3, 3),
},
{
name: "3 months",
date: task.NewDate(2021, 5, 3),
exp: true,
},
{
name: "4 months",
date: task.NewDate(2021, 6, 3),
},
{
name: "6 months",
date: task.NewDate(2021, 8, 3),
exp: true, exp: true,
}, },
} { } {