當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。