From 0563006c5510c7c71bd70b7bffb862b502fc20d0 Mon Sep 17 00:00:00 2001 From: fumiama Date: Tue, 26 Oct 2021 22:24:28 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E4=BF=AE=E5=A4=8D=20timer=20?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin_manager/timer/timer.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugin_manager/timer/timer.go b/plugin_manager/timer/timer.go index 5b30f550..b3acbc61 100644 --- a/plugin_manager/timer/timer.go +++ b/plugin_manager/timer/timer.go @@ -61,19 +61,22 @@ func (ts *Timer) nextWakeTime() (date time.Time) { h := ts.Hour mn := ts.Minute w := ts.Week - unit := time.Minute + unit := time.Duration(int(ts.Minute) - date.Minute()) if mn >= 0 { switch { case h < 0: - unit = time.Hour + if unit < 0 { + unit += time.Hour + } case d < 0: - unit = time.Hour * 24 + unit += time.Hour * 24 case w < 0: - unit = time.Hour * 24 * 7 + unit += time.Hour * 24 * 7 case m < 0: unit = -1 - default: } + } else { + unit = time.Minute } stable := 0 if mn < 0 { @@ -130,7 +133,7 @@ func (ts *Timer) nextWakeTime() (date time.Time) { default: date = date.AddDate(1, 0, 0) } - date = firstWeek(&date, time.Weekday(ts.Week)) + date = firstWeek(&date, time.Weekday(w)) } return date }