monthly recur fix
This commit is contained in:
parent
2ea3639505
commit
d3cc6f4206
|
@ -260,7 +260,18 @@ func (enm EveryNMonths) RecursOn(date Date) bool {
|
|||
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 {
|
||||
|
|
|
@ -338,6 +338,19 @@ func TestEveryNMonths(t *testing.T) {
|
|||
{
|
||||
name: "one month",
|
||||
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,
|
||||
},
|
||||
} {
|
||||
|
|
Loading…
Reference in New Issue