GetTimeAfter() public method

Gets the next fire time after the given time.
public GetTimeAfter ( DateTimeOffset afterTimeUtc ) : DateTimeOffset?
afterTimeUtc DateTimeOffset The UTC time to start searching from.
return DateTimeOffset?
        public DateTimeOffset GetNextScheduleFromQuartzExpression(DateTimeOffset withinThisMinute)
        {
            var expression = new CronExpression(job.Crontab);

            var startMinute = new DateTimeOffset(withinThisMinute.Year, withinThisMinute.Month, withinThisMinute.Day, withinThisMinute.Hour, withinThisMinute.Minute, 0, 0, withinThisMinute.Offset);
            startMinute = startMinute.AddMilliseconds(-1);

            var result = DateTimeOffset.MinValue;

            var nextOccurrence = expression.GetTimeAfter(startMinute.ToUniversalTime());
            if (nextOccurrence.HasValue)
            {
                var isWithinTheNextMinute = 60 > Math.Abs((nextOccurrence.Value.LocalDateTime - startMinute).TotalSeconds);
                Trace.WriteLine("CronExp: Id {0} ('{1}'): '{2}' [{3}].", job.Id, job.Crontab, nextOccurrence.Value.ToString("yyyy-MM-dd HH:mm:sszzz"), isWithinTheNextMinute);
                if (isWithinTheNextMinute)
                {
                    result = nextOccurrence.Value.LocalDateTime;
                }
            }
            else
            {
                Trace.WriteLine("CronExp: Id {0} ('{1}'): '{2}' [{3}].", job.Id, job.Crontab, result.ToString("yyyy-MM-dd HH:mm:sszzz"), false);
            }

            return result;
        }
        public void TestCronExpression()
        {
            //[秒] [分] [小时] [日] [月] [周] [年]
            //实例化表达式类,把字符串转成一个对象
            CronExpression expression = new CronExpression("0 15 10 * * ? 2012");

            while (true)
            {
                DateTimeOffset utcNow = SystemTime.UtcNow();
                Console.WriteLine("UtcNow - " + utcNow);

                //Console.WriteLine("GetFinalFireTime - " + expression.GetFinalFireTime());这个方法没有实现
                //得到给定时间下一个无效的时间
                Console.WriteLine("GetNextInvalidTimeAfter - " + expression.GetNextInvalidTimeAfter(utcNow));
                //得到给定时间的下一个有效的时间
                Console.WriteLine("GetNextValidTimeAfter - " + expression.GetNextValidTimeAfter(utcNow));
                //得到给定时间下一个符合表达式的时间
                Console.WriteLine("GetTimeAfter - " + expression.GetTimeAfter(utcNow));
                //Console.WriteLine("GetTimeBefore - " + expression.GetTimeBefore(utcNow));这个方法没有实现
                //给定时间是否符合表达式
                Console.WriteLine("IsSatisfiedBy - " + expression.IsSatisfiedBy(new DateTimeOffset(2012, 4, 6, 2, 15, 0, TimeSpan.Zero)));
                Console.WriteLine(expression.TimeZone);
                Console.WriteLine("------------------------------------");
                Console.WriteLine(expression.GetExpressionSummary());
                Console.Read();
            }
        }