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


C# DateTime.AddWorkingDays方法代码示例

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


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

示例1: adding_working_days_should_not_count_weekends

        public void adding_working_days_should_not_count_weekends()
        {
            DateTime startDate = new DateTime(2011, 5, 2); //Monday
            DateTime referenceDate = startDate;
            Assert.IsTrue(startDate.DayOfWeek == DayOfWeek.Monday);
            Assert.IsTrue(startDate == referenceDate);

            DateTime startPlus5 = startDate.AddWorkingDays( 5, pt_ci);
            Assert.IsTrue(startPlus5.DayOfWeek == DayOfWeek.Monday);

            DateTime startPlus4 = startDate.AddWorkingDays( 4, pt_ci);
            Assert.IsTrue(startPlus4.DayOfWeek == DayOfWeek.Friday);

            Assert.IsTrue(startDate == referenceDate);
        }
开发者ID:Erls-Corporation,项目名称:DateTimeExtensions,代码行数:15,代码来源:PTCalendarTests.cs

示例2: AddWorkingDays_ZeroDays

        public void AddWorkingDays_ZeroDays()
        {
            DateTime testDate = new DateTime(2014, 2, 8);

            var result = testDate.AddWorkingDays(0);

            Assert.AreEqual(testDate, result);
        }
开发者ID:RichardAllanBrown,项目名称:ShinyDate,代码行数:8,代码来源:ShinyDateWorkingDays_Test.cs

示例3: AddWorkingDays_MultipleDays

        public void AddWorkingDays_MultipleDays()
        {
            DateTime testDate = new DateTime(2014, 2, 8);

            var result = testDate.AddWorkingDays(25);

            Assert.AreEqual(new DateTime(2014, 3, 14), result);
        }
开发者ID:RichardAllanBrown,项目名称:ShinyDate,代码行数:8,代码来源:ShinyDateWorkingDays_Test.cs

示例4: adding_large_number_of_days

        public void adding_large_number_of_days()
        {
            DateTime startDate = new DateTime(2011, 5, 2); //Monday
            Assert.IsTrue(startDate.DayOfWeek == DayOfWeek.Monday);

            DateTime startPlus60 = startDate.AddWorkingDays(60, foo_ci);
            Assert.IsTrue(startPlus60.DayOfWeek == DayOfWeek.Monday);
        }
开发者ID:kappy,项目名称:DateTimeExtensions,代码行数:8,代码来源:GenericCalendarTests.cs

示例5: adding_zero_working_days_should_return_same_day

        public void adding_zero_working_days_should_return_same_day()
        {
            DateTime startDate = new DateTime(2011, 5, 2); //Monday
            Assert.IsTrue(startDate.DayOfWeek == DayOfWeek.Monday);

            DateTime startPlus0 = startDate.AddWorkingDays( 0, pt_ci);
            Assert.IsTrue(startPlus0.DayOfWeek == DayOfWeek.Monday);
            Assert.IsTrue(startDate == startPlus0);
        }
开发者ID:Erls-Corporation,项目名称:DateTimeExtensions,代码行数:9,代码来源:PTCalendarTests.cs

示例6: adding_large_number_of_days

        public void adding_large_number_of_days()
        {
            DateTime startDate = new DateTime(2011, 5, 2); //Monday
            Assert.IsTrue(startDate.DayOfWeek == DayOfWeek.Monday);

            //we substract 2 working day because in 60 days we get an holiday at 10-6 and another at 23-6
            DateTime startPlus60 = startDate.AddWorkingDays( 60 - 2, pt_ci);
            Assert.IsTrue(startPlus60.DayOfWeek == DayOfWeek.Monday);
        }
开发者ID:Erls-Corporation,项目名称:DateTimeExtensions,代码行数:9,代码来源:PTCalendarTests.cs

示例7: globally_recomended_calculation

        public void globally_recomended_calculation()
        {
            //Ensure we're running on portuguese context
            Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-PT");

            var friday = new DateTime(2011, 5, 13); // A friday
            var friday_plus_two_working_days = friday.AddWorkingDays(2); // friday + 2 working days

            Assert.IsTrue(friday_plus_two_working_days == friday.AddDays(4));
            Assert.IsTrue(friday_plus_two_working_days.DayOfWeek == DayOfWeek.Tuesday);
        }
开发者ID:marinovdh,项目名称:DateTimeExtensions,代码行数:11,代码来源:ExampleTests.cs

示例8: holidays

        public void holidays()
        {
            var ptWorkingDayCultureInfo = new DateTimeCultureInfo("pt-PT");
            var enWorkingDayCultureInfo = new DateTimeCultureInfo("default");

            var thursday = new DateTime(2011, 4, 21); // A thursday
            var thursday_plus_two_working_days_pt = thursday.AddWorkingDays(2, ptWorkingDayCultureInfo); // friday + 2 working days on PT
            var thursday_plus_two_working_days_en = thursday.AddWorkingDays(2, enWorkingDayCultureInfo); // friday + 2 working days on Default

            //Default doesn't have supported holidays
            Assert.IsTrue(thursday_plus_two_working_days_en == thursday.AddDays(4));
            Assert.IsTrue(thursday_plus_two_working_days_en.DayOfWeek == DayOfWeek.Monday);

            //Portuguese Holidays are supported
            Assert.IsTrue(thursday_plus_two_working_days_pt == thursday.AddDays(6)); // + Good Friday (22-4-2011) + Carnation Revolution (25-4-2011)
            Assert.IsTrue(thursday_plus_two_working_days_pt.DayOfWeek == DayOfWeek.Wednesday);
        }
开发者ID:frankgeerlings,项目名称:DateTimeExtensions,代码行数:17,代码来源:ExampleTests.cs

示例9: simple_calculation

        public void simple_calculation()
        {
            var friday = new DateTime(2011,5,13); // A friday
            var friday_plus_two_working_days = friday.AddWorkingDays(2); // friday + 2 working days

            Assert.IsTrue(friday_plus_two_working_days == friday.AddDays(4));
            Assert.IsTrue(friday_plus_two_working_days.DayOfWeek == DayOfWeek.Tuesday);

            //not recomended because the default DateTimeCultureInfo by default is pulled from current CultureInfo
        }
开发者ID:frankgeerlings,项目名称:DateTimeExtensions,代码行数:10,代码来源:ExampleTests.cs

示例10: recomended_calculation

        public void recomended_calculation()
        {
            var workingDayCultureInfo = new DateTimeCultureInfo("pt-PT");
            var friday = new DateTime(2011, 5, 13); // A friday
            var friday_plus_two_working_days = friday.AddWorkingDays(2, workingDayCultureInfo); // friday + 2 working days

            Assert.IsTrue(friday_plus_two_working_days == friday.AddDays(4));
            Assert.IsTrue(friday_plus_two_working_days.DayOfWeek == DayOfWeek.Tuesday);
        }
开发者ID:frankgeerlings,项目名称:DateTimeExtensions,代码行数:9,代码来源:ExampleTests.cs

示例11: subtracting_working_days_should_not_count_weekends

        public void subtracting_working_days_should_not_count_weekends()
        {
            DateTime startDate = new DateTime(2011, 5, 9); //Monday
            DateTime referenceDate = startDate;
            Assert.IsTrue(startDate.DayOfWeek == DayOfWeek.Monday);
            Assert.IsTrue(startDate == referenceDate);

            DateTime startMinus5 = startDate.AddWorkingDays( -5, pt_ci);
            Assert.IsTrue(startMinus5.DayOfWeek == DayOfWeek.Monday);

            DateTime startMinus1 = startDate.AddWorkingDays( -1, pt_ci);
            Assert.IsTrue(startMinus1.DayOfWeek == DayOfWeek.Friday);

            Assert.IsTrue(startDate == referenceDate);
        }
开发者ID:Erls-Corporation,项目名称:DateTimeExtensions,代码行数:15,代码来源:PTCalendarTests.cs

示例12: use_holidays_in_calulations

        public void use_holidays_in_calulations()
        {
            DateTime startDate = new DateTime(2011, 4, 21);

            //21-04-2011 - start
            //22-04-2011 - holiday
            //23-04-2011 - saturday
            //24-04-2011 - sunday
            //25-04-2011 - holiday
            //26-04-2011 - end

            DateTime endDate = startDate.AddWorkingDays( 1, pt_ci);
            Assert.IsTrue(endDate == startDate.AddDays(5), "Expecting 26-04-2011 but got " + endDate.ToShortDateString());
        }
开发者ID:Erls-Corporation,项目名称:DateTimeExtensions,代码行数:14,代码来源:PTCalendarTests.cs


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