using System;

namespace Scalider.Jobs.Schedule
{

    /// <summary>
    /// Provides a <see cref="IJobScheduler"/> that uses a fixed interval to calculate the next
    /// job execution occurrence.
    /// </summary>
    public class TimeSpanScheduler : IJobScheduler
    {

        private readonly TimeSpan _interval;

        /// <summary>
        /// Initializes a new instance of the <see cref="TimeSpanScheduler"/> class.
        /// </summary>
        /// <param name="interval"></param>
        public TimeSpanScheduler(TimeSpan interval)
        {
            _interval = interval;
        }

        /// <inheritdoc />
        public DateTimeOffset? GetNextOccurrence(DateTimeOffset utcNow) => utcNow.Add(_interval);

    }

}
