本文整理汇总了C#中CronExpression.GetNextValidTimeAfter方法的典型用法代码示例。如果您正苦于以下问题:C# CronExpression.GetNextValidTimeAfter方法的具体用法?C# CronExpression.GetNextValidTimeAfter怎么用?C# CronExpression.GetNextValidTimeAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CronExpression
的用法示例。
在下文中一共展示了CronExpression.GetNextValidTimeAfter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCronExpressionPassingYear
public void TestCronExpressionPassingYear()
{
DateTimeOffset start = new DateTime(2007, 12, 1, 23, 59, 59).ToUniversalTime();
CronExpression ce = new CronExpression("0 55 15 1 * ?");
DateTimeOffset expected = new DateTime(2008, 1, 1, 15, 55, 0).ToUniversalTime();
DateTimeOffset d = ce.GetNextValidTimeAfter(start).Value;
Assert.AreEqual(expected, d, "Got wrong date and time when passed year");
}
示例2: TestYearChange
public void TestYearChange()
{
// QRTZNET-85
CronExpression cronExpression = new CronExpression("0 12 4 ? * 3");
cronExpression.GetNextValidTimeAfter(new DateTime(2007, 12, 28));
}
示例3: TestGetTimeAfter_QRTZNET149
public void TestGetTimeAfter_QRTZNET149()
{
CronExpression expression = new CronExpression("0 0 0 29 * ?");
DateTimeOffset? after = expression.GetNextValidTimeAfter(new DateTime(2009, 1, 30, 0, 0, 0).ToUniversalTime());
Assert.IsTrue(after.HasValue);
Assert.AreEqual(new DateTime(2009, 3, 29, 0, 0, 0).ToUniversalTime(), after.Value.DateTime);
after = expression.GetNextValidTimeAfter(new DateTime(2009, 12, 30).ToUniversalTime());
Assert.IsTrue(after.HasValue);
Assert.AreEqual(new DateTime(2010, 1, 29, 0, 0, 0).ToUniversalTime(), after.Value.DateTime);
}
示例4: TestQRTZNET152
public void TestQRTZNET152()
{
CronExpression expression = new CronExpression("0 5 13 5W 1-12 ?");
DateTimeOffset test = new DateTimeOffset(2009, 3, 8, 0, 0, 0, TimeSpan.Zero);
DateTimeOffset d = expression.GetNextValidTimeAfter(test).Value;
Assert.AreEqual(new DateTimeOffset(2009, 4, 6, 13, 5, 0, TimeZoneInfo.Local.GetUtcOffset(test)).ToUniversalTime(), d);
d = expression.GetNextValidTimeAfter(d).Value;
Assert.AreEqual(new DateTimeOffset(2009, 5, 5, 13, 5, 0, TimeZoneInfo.Local.GetUtcOffset(d)), d);
}
示例5: TestDaylightSaving_QRTZNETZ186
public void TestDaylightSaving_QRTZNETZ186()
{
CronExpression expression = new CronExpression("0 15 * * * ?");
if (!TimeZoneInfo.Local.SupportsDaylightSavingTime)
{
return;
}
var daylightChange = TimeZone.CurrentTimeZone.GetDaylightChanges(2012);
DateTimeOffset before = daylightChange.Start.ToUniversalTime().AddMinutes(-5); // keep outside the potentially undefined interval
DateTimeOffset? after = expression.GetNextValidTimeAfter(before);
Assert.IsTrue(after.HasValue);
DateTimeOffset expected = daylightChange.Start.Add(daylightChange.Delta).AddMinutes(15).ToUniversalTime();
Assert.AreEqual(expected, after.Value);
}