From e214faa625c6e3feb97b63a2a0b7961311389c2c Mon Sep 17 00:00:00 2001 From: Fred Date: Mon, 28 Oct 2024 21:15:09 +0000 Subject: [PATCH] quick fix for #378 --- calendar/event.go | 1 + calendar/event_test.go | 4 ++-- schedule/schedules.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/calendar/event.go b/calendar/event.go index 0360ddd9..63479d67 100644 --- a/calendar/event.go +++ b/calendar/event.go @@ -97,6 +97,7 @@ func (e *Event) Parse(input string) error { func (e *Event) Next(from time.Time) time.Time { // start from time and increment of 1 minute each time next := from.Truncate(time.Minute) // truncate all the seconds + next = next.Add(time.Minute) // it's too late for the current minute // should stop in 2 years time to avoid an infinite loop endYear := from.Year() + 2 for next.Year() <= endYear { diff --git a/calendar/event_test.go b/calendar/event_test.go index 9d505c01..9cd0d97a 100644 --- a/calendar/event_test.go +++ b/calendar/event_test.go @@ -163,10 +163,10 @@ func TestNextTrigger(t *testing.T) { require.NoError(t, err) testData := []struct{ event, trigger string }{ - {"*:*:*", "2006-01-02 15:04:00"}, // seconds are zeroed out + {"*:*:*", "2006-01-02 15:05:00"}, // seconds are zeroed out => take next minute {"03-*", "2006-03-01 00:00:00"}, {"*-01", "2006-02-01 00:00:00"}, - {"*:*:11", "2006-01-02 15:04:00"}, // again, seconds are zeroed out + {"*:*:11", "2006-01-02 15:05:00"}, // again, seconds are zeroed out {"*:11:*", "2006-01-02 15:11:00"}, {"11:*:*", "2006-01-03 11:00:00"}, {"tue", "2006-01-03 00:00:00"}, diff --git a/schedule/schedules.go b/schedule/schedules.go index 9abe12cd..582aeafc 100644 --- a/schedule/schedules.go +++ b/schedule/schedules.go @@ -52,7 +52,7 @@ func displayParsedSchedules(profile, command string, events []*calendar.Event) { term.Printf(" (in UTC): %s\n", next.UTC().Format(time.UnixDate)) term.Printf(" From now: %s left\n", next.Sub(now)) } - term.Print("\n") + term.Print(platform.LineSeparator) } func displaySystemdSchedules(profile, command string, schedules []string) error { @@ -69,6 +69,6 @@ func displaySystemdSchedules(profile, command string, schedules []string) error return err } } - term.Print("\n") + term.Print(platform.LineSeparator) return nil }