using eSuite.Core.Clock;

namespace e_suite.Scheduler.Scheduler;

[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class IntervalAttribute : Attribute, ISchedule
{
    public TimeSpan Interval { get; }

    public IntervalAttribute(int hours, int minutes)
    {
        Interval = new TimeSpan(hours, minutes, 0);
    }

    public IntervalAttribute(int days, int hours, int minutes)
    {
        Interval = new TimeSpan(days, hours, minutes, 0);
    }

    public DateTimeOffset NextScheduledExecution(IClock clock)
    {
        return clock.GetNow.Add(Interval);
    }
}