Core/CafeLib.Core/Extensions/DateTimeExtensions.cs
/// <summary>
/// Adds interval to datetime until greater than current utc time.
/// </summary>
/// <param name="dateTime">date time</param>
/// <param name="interval">interval time span</param>
/// <returns>datetime</returns>
Adds interval to datetime until greater than current utc time.
Adds interval to datetime until greater than current utc time .
public static DateTime NextTimeUtc(this DateTime dateTime, TimeSpan interval)
        {
            var timespan = dateTime < DateTime.UtcNow
                ? interval != TimeSpan.Zero ? interval : throw new ArgumentException($"Zero {nameof(interval)} results in endless loop.")
                : TimeSpan.Zero;
            var nextTime = dateTime.Add(timespan);
            while (nextTime < DateTime.UtcNow)
            {
                nextTime = nextTime.Add(timespan);
            }
            return nextTime;
        }
public static DateTime NextTimeUtc ( this DateTime dateTime , TimeSpan interval ) { var timespan = dateTime < DateTime . UtcNow ? interval != TimeSpan . Zero ? interval : throw new ArgumentException ( $" Zero  { nameof ( interval ) }  results in endless loop. " ) : TimeSpan . Zero ; var nextTime = dateTime . Add ( timespan ) ; while ( nextTime < DateTime . UtcNow ) { nextTime = nextTime . Add ( timespan ) ; } return nextTime ; }
Adds interval to datetime until greater than current utc time.
Adds interval to datetime until greater than current utc time .
None
DateTime
this
interval
TimeSpan
interval time span
interval time span
dateTime
None