public void Test() { var cronExp = new CronExpression("0 */1 * * * ? ");//从0秒开始每5秒执行一次 var sum = cronExp.GetExpressionSummary(); var now = SystemTime.Now(); var runTime = cronExp.GetNextValidTimeAfter(now); //Meta.Execution.LastSucceedRun.Value.ToUniversalTime() Console.WriteLine($"Now:{now};NextTime:{(runTime)}[{sum}]"); //Assert.IsTrue(runTime.Value == now.AddMilliseconds(5)); }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns> /// A new object that is a copy of this instance. /// </returns> public object Clone() { CronExpression copy; try { copy = new CronExpression(CronExpressionString) {TimeZone = TimeZone}; } catch (FormatException) { // never happens since the source is valid... throw new Exception("Not Cloneable."); } return copy; }