package schedule

import "time"

type ConstantSchedule struct {
	Interval time.Duration
}

func Every(duration time.Duration) ConstantSchedule {
	if duration < time.Second {
		duration = time.Second
	}
	duration = duration - time.Duration(duration.Nanoseconds())%time.Second
	return ConstantSchedule{
		Interval: duration,
	}
}

func (c ConstantSchedule) Next(current time.Time) time.Time {
	return current.Add(c.Interval).Round(1 * time.Second)
}

package schedule

import "time"

type ConstantSchedule struct {
	Interval time.Duration
}

func Every(duration time.Duration) ConstantSchedule {
	if duration < time.Second {
		duration = time.Second
	}
	duration = duration - time.Duration(duration.Nanoseconds())%time.Second
	return ConstantSchedule{
		Interval: duration,
	}
}

func (c ConstantSchedule) Next(current time.Time) time.Time {
	return current.Add(c.Interval - time.Duration(current.Nanosecond())*time.Nanosecond)
}

Remove nanoseconds from Next's time in ConstantSchedule
Remove nanoseconds from Next's time in ConstantSchedule
