reugn/go-quartz

some questions about NextFireTime

gengquanying opened this issue · 2 comments

I use the test code:

now := time.Now()

fmt.Println(utils.TimeFormat(now))

loc, _ := time.LoadLocation("Asia/Shanghai")

ctrigger1, _ := quartz.NewCronTriggerWithLoc("0 * * ? * *", loc)

ne1, _ := ctrigger1.NextFireTime(now.UnixNano())

fmt.Println(utils.TimeFormat(time.Unix(ne1/int64(time.Second), 0)))

ctrigger2, _ := quartz.NewCronTriggerWithLoc("0 * * ? * MON", loc)

ne2, _ := ctrigger2.NextFireTime(now.UnixNano())

fmt.Println(utils.TimeFormat(time.Unix(ne2/int64(time.Second), 0)))

ctrigger3, _ := quartz.NewCronTriggerWithLoc("0 * * ? * 1", loc)

ne3, _ := ctrigger3.NextFireTime(now.UnixNano())

fmt.Println(utils.TimeFormat(time.Unix(ne3/int64(time.Second), 0)))

then I got:

2022-06-27 18:32:23
2022-06-27 18:33:00
2022-07-04 18:32:00
2022-07-03 18:32:00

the third and the fourth output are not as I expected, is this correct?

@gengquanying I didn't test yet but fourth one is Next Sunday (2022-07-03 18:32:00) and third one is Next Monday (2022-07-04 18:32:00). So I feel like it's correct.

image

reugn commented

Closing due to inactivity.