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


C# DateTime.countNewYearBreaks方法代码示例

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


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

示例1: countExcludedItems

        private static int countExcludedItems(DateTime startDate, DateTime endDate, TimeframeSymbol timeframe)
        {
            int weekends = 0;
            int christmas = 0;
            int newYears = 0;
            int sign = (startDate.CompareTo(endDate) < 0 ? 1 : -1);

            weekends = countWeekendItems(startDate, endDate, timeframe);
            newYears = sign * startDate.countNewYearBreaks(endDate, false) * (dayUnitsForTimeframe(timeframe) + getTimeframeHolidayInactiveUnits(timeframe));
            christmas = sign * startDate.countChristmas(endDate, false) * (dayUnitsForTimeframe(timeframe) + getTimeframeHolidayInactiveUnits(timeframe));

            return (weekends + christmas + newYears);
        }
开发者ID:mielk,项目名称:waluty,代码行数:13,代码来源:Timeframe.cs

示例2: countNewYearBreaks_if_dates_in_the_same_year_positive_difference_zero_is_returned

        public void countNewYearBreaks_if_dates_in_the_same_year_positive_difference_zero_is_returned()
        {
            DateTime baseDate = new DateTime(2016, 1, 4);
            DateTime comparedDate = new DateTime(2016, 1, 10);

            Assert.AreEqual(0, baseDate.countNewYearBreaks(comparedDate, true));
        }
开发者ID:mielk,项目名称:waluty,代码行数:7,代码来源:HelperMethodsUnitTests.cs

示例3: addTimeUnits_days

        private static DateTime addTimeUnits_days(DateTime date, int units)
        {
            int remainder = units % 5;
            int newWeekDay = (int)date.DayOfWeek + remainder;
            bool breakWeek = newWeekDay > 5 || newWeekDay <= 0;
            int daysToAdd = (units / 5) * 7 + remainder + Math.Sign(units) * (breakWeek ? 2 : 0);
            DateTime newDate = date.AddDays(daysToAdd);

            //Include year breaks.
            int yearBreaks = date.countNewYearBreaks(newDate, false);
            int christmas = date.countChristmas(newDate, false);
            if (yearBreaks + christmas > 0)
            {
                newDate = addTimeUnits_days(newDate, Math.Sign(units) * (yearBreaks + christmas));
            }

            //Check if the result date is not New Year nor Christmas.
            while (newDate.DayOfWeek == DayOfWeek.Sunday || newDate.DayOfWeek == DayOfWeek.Saturday || newDate.DayOfYear == 1 || newDate.IsChristmas())
            {
                int sign = Math.Sign(units);
                newDate = newDate.AddDays(sign);
            }

            return newDate;
        }
开发者ID:mielk,项目名称:waluty,代码行数:25,代码来源:Timeframe.cs

示例4: countNewYearBreaks_correct_value_is_returned_for_positive_difference_including_weekends

        public void countNewYearBreaks_correct_value_is_returned_for_positive_difference_including_weekends()
        {
            DateTime baseDate = new DateTime(2010, 12, 30);
            DateTime comparedDate = new DateTime(2016, 1, 4);

            Assert.AreEqual(6, baseDate.countNewYearBreaks(comparedDate, true));
        }
开发者ID:mielk,项目名称:waluty,代码行数:7,代码来源:HelperMethodsUnitTests.cs

示例5: DateTime

        public void countNewYearBreaks_correct_value_is_returned_for_date_from_previous_year_NY_at_week_including_weekends()
        {
            DateTime baseDate = new DateTime(2016, 1, 4);
            DateTime comparedDate = new DateTime(2015, 12, 30);

            Assert.AreEqual(1, baseDate.countNewYearBreaks(comparedDate, true));
        }
开发者ID:mielk,项目名称:waluty,代码行数:7,代码来源:HelperMethodsUnitTests.cs

示例6: countNewYearBreaks_both_dates_are_weekend_newYears_weekend_included

        public void countNewYearBreaks_both_dates_are_weekend_newYears_weekend_included()
        {
            DateTime baseDate = new DateTime(2012, 1, 1);
            DateTime comparedDate = new DateTime(2017, 1, 1);

            Assert.AreEqual(5, baseDate.countNewYearBreaks(comparedDate, true));
        }
开发者ID:mielk,项目名称:waluty,代码行数:7,代码来源:HelperMethodsUnitTests.cs

示例7: countNewYearBreaks_both_dates_are_newYears_one_of_them_weekend_weekends_included

        public void countNewYearBreaks_both_dates_are_newYears_one_of_them_weekend_weekends_included()
        {
            DateTime baseDate = new DateTime(2016, 1, 1);
            DateTime comparedDate = new DateTime(2017, 1, 1);

            Assert.AreEqual(1, baseDate.countNewYearBreaks(comparedDate, true));
        }
开发者ID:mielk,项目名称:waluty,代码行数:7,代码来源:HelperMethodsUnitTests.cs


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