当前位置: 首页>>代码示例>>C#>>正文


C# CronExpression.GetTimeAfter方法代码示例

本文整理汇总了C#中CronExpression.GetTimeAfter方法的典型用法代码示例。如果您正苦于以下问题:C# CronExpression.GetTimeAfter方法的具体用法?C# CronExpression.GetTimeAfter怎么用?C# CronExpression.GetTimeAfter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CronExpression的用法示例。


在下文中一共展示了CronExpression.GetTimeAfter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCronExpressionPassingMidnight

 public void TestCronExpressionPassingMidnight()
 {
     CronExpression cronExpression = new CronExpression("0 15 23 * * ?");
     DateTimeOffset cal = new DateTime(2005, 6, 1, 23, 16, 0).ToUniversalTime();
     DateTimeOffset nextExpectedFireTime = new DateTime(2005, 6, 2, 23, 15, 0).ToUniversalTime();
     Assert.AreEqual(nextExpectedFireTime, cronExpression.GetTimeAfter(cal).Value);
 }
开发者ID:apobekiaris,项目名称:quartznet,代码行数:7,代码来源:CronExpressionTest.cs

示例2: TestCorrectWeekFireDays

        private static void TestCorrectWeekFireDays(CronExpression cronExpression, IList<int> correctFireDays)
        {
            List<int> fireDays = new List<int>();

            DateTime cal = new DateTime(2007, 6, 1, 11, 0, 0).ToUniversalTime();
            for (int i = 0; i < DateTime.DaysInMonth(2007, 6); ++i)
            {
                DateTimeOffset? nextFireTime = cronExpression.GetTimeAfter(cal);
                if (!fireDays.Contains(nextFireTime.Value.Day) && nextFireTime.Value.Month == 6)
                {
                    // next fire day may be monday for several days..
                    fireDays.Add(nextFireTime.Value.Day);
                }
                cal = cal.AddDays(1);
            }
            // check rite dates fired
            for (int i = 0; i < fireDays.Count; ++i)
            {
                int idx = correctFireDays.IndexOf(fireDays[i]);
                Assert.Greater(idx, -1,
                               string.Format("CronExpression evaluated true for {0} even when it shouldn't have", fireDays[i]));
                correctFireDays.RemoveAt(idx);
            }

            // check that all fired
            Assert.IsTrue(correctFireDays.Count == 0, string.Format("CronExpression did not evaluate true for all expected days (count: {0}).", correctFireDays.Count));
        }
开发者ID:apobekiaris,项目名称:quartznet,代码行数:27,代码来源:CronExpressionTest.cs

示例3: TestMonthShift

 public void TestMonthShift()
 {
     // QRTZNET-28
     CronExpression cronExpression = new CronExpression("* * 1 * * ?");
     DateTimeOffset cal = new DateTime(2005, 7, 31, 22, 59, 57).ToUniversalTime();
     DateTimeOffset nextExpectedFireTime = new DateTime(2005, 8, 1, 1, 0, 0).ToUniversalTime();
     Assert.AreEqual(nextExpectedFireTime, cronExpression.GetTimeAfter(cal).Value);
 }
开发者ID:apobekiaris,项目名称:quartznet,代码行数:8,代码来源:CronExpressionTest.cs

示例4: TestHourShift

 public void TestHourShift()
 {
     // cronexpression that fires every 5 seconds
     CronExpression cronExpression = new CronExpression("0/5 * * * * ?");
     DateTimeOffset cal = new DateTimeOffset(2005, 6, 1, 1, 59, 55, TimeSpan.Zero);
     DateTimeOffset nextExpectedFireTime = new DateTimeOffset(2005, 6, 1, 2, 0, 0, TimeSpan.Zero);
     Assert.AreEqual(nextExpectedFireTime, cronExpression.GetTimeAfter(cal).Value);
 }
开发者ID:apobekiaris,项目名称:quartznet,代码行数:8,代码来源:CronExpressionTest.cs

示例5: TestDaylightSavingsDoesNotMatchAnHourBefore2

        public void TestDaylightSavingsDoesNotMatchAnHourBefore2()
        {
            //another case
            TimeZoneInfo est = TimeZoneUtil.FindTimeZoneById("Eastern Standard Time");
            CronExpression expression = new CronExpression("0 0 0 ? * THU");
            expression.TimeZone = est;

            DateTimeOffset startTime = new DateTimeOffset(2012, 11, 4, 0, 0, 0, TimeSpan.Zero);

            var actualTime = expression.GetTimeAfter(startTime);
            DateTimeOffset expected = new DateTimeOffset(2012, 11, 8, 0, 0, 0, TimeSpan.FromHours(-5));
            Assert.AreEqual(expected, actualTime);
        }
开发者ID:CharlieBP,项目名称:quartznet,代码行数:13,代码来源:CronExpressionTest.cs

示例6: TestDaylightSavingsDoesNotMatchAnHourBefore

        public void TestDaylightSavingsDoesNotMatchAnHourBefore()
        {
            TimeZoneInfo est = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
            CronExpression expression = new CronExpression("0 15 15 5 11 ?");
            expression.TimeZone = est;

            DateTimeOffset startTime = new DateTimeOffset(2012, 11, 4, 0, 0, 0, TimeSpan.Zero);

            var actualTime = expression.GetTimeAfter(startTime);
            DateTimeOffset expected = new DateTimeOffset(2012, 11, 5, 15, 15, 0, TimeSpan.FromHours(-5));

            Assert.AreEqual(expected, actualTime.Value);
        }
开发者ID:herrmic,项目名称:quartznet,代码行数:13,代码来源:CronExpressionTest.cs


注:本文中的CronExpression.GetTimeAfter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。