Skip to content

Commit

Permalink
quick fix for #378
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects committed Oct 28, 2024
1 parent 891081c commit e214faa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions calendar/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions calendar/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
4 changes: 2 additions & 2 deletions schedule/schedules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -69,6 +69,6 @@ func displaySystemdSchedules(profile, command string, schedules []string) error
return err
}
}
term.Print("\n")
term.Print(platform.LineSeparator)
return nil
}

0 comments on commit e214faa

Please sign in to comment.