public IEnumerable <DateTime> GetNextInstants(DateTime lastInstant) { if (lastInstant.Kind != DateTimeKind.Utc) { throw new ArgumentException("Only DateTime values in UTC should be passed.", nameof(lastInstant)); } return(_schedule .GetNextOccurrences( TimeZoneInfo.ConvertTime(lastInstant, TimeZoneInfo.Utc, _timeZone), TimeZoneInfo.ConvertTime(NowInstant.AddSeconds(1), TimeZoneInfo.Utc, _timeZone)) .Where(x => !_timeZone.IsInvalidTime(x)) .Select(x => TimeZoneInfo.ConvertTime(x, _timeZone, TimeZoneInfo.Utc)) .ToList()); }
public IEnumerable <DateTime> GetNextInstants(DateTime?lastInstant) { if (lastInstant.HasValue && lastInstant.Value.Kind != DateTimeKind.Utc) { throw new ArgumentException("Only DateTime values in UTC should be passed.", "lastInstant"); } var baseTime = lastInstant ?? NowInstant.AddSeconds(-1); var endTime = NowInstant.AddSeconds(1); return(_schedule .GetNextOccurrences( TimeZoneInfo.ConvertTimeFromUtc(baseTime, _timeZone), TimeZoneInfo.ConvertTimeFromUtc(endTime, _timeZone)) .Select(x => TimeZoneInfo.ConvertTimeToUtc(x, _timeZone)) .ToList()); }