go-quartz icon indicating copy to clipboard operation
go-quartz copied to clipboard

some questions about NextFireTime

Open gengquanying opened this issue 3 years ago • 1 comments
trafficstars

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 avatar Jun 27 '22 10:06 gengquanying

@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

yusufozturk avatar Aug 10 '22 11:08 yusufozturk

Closing due to inactivity.

reugn avatar Oct 10 '23 11:10 reugn