public ScheduleInstant(DateTime nowInstant, TimeZoneInfo timeZone, [NotNull] CrontabSchedule schedule)
{
if (schedule == null) throw new ArgumentNullException("schedule");
if (nowInstant.Kind != DateTimeKind.Utc)
{
throw new ArgumentException("Only DateTime values in UTC should be passed.", "nowInstant");
}
_timeZone = timeZone;
_schedule = schedule;
NowInstant = nowInstant.AddSeconds(-nowInstant.Second);
var nextOccurrences = _schedule.GetNextOccurrences(
TimeZoneInfo.ConvertTime(NowInstant, TimeZoneInfo.Utc, _timeZone),
DateTime.MaxValue);
foreach (var nextOccurrence in nextOccurrences)
{
if (_timeZone.IsInvalidTime(nextOccurrence)) continue;
NextInstant = TimeZoneInfo.ConvertTime(nextOccurrence, _timeZone, TimeZoneInfo.Utc);
break;
}
}