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


C# GregorianCalendar.AddDays方法代码示例

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


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

示例1: GetDaylightChanges

        /// <summary>
        /// Returns the daylight changes for UTC (never).
        /// </summary>
        public override DaylightTime GetDaylightChanges(int year)
        {
            // We need a start and stop time
            DateTime start, end;
            Calendar cal = new GregorianCalendar();

            // 2007+ at this point has a slightly different start/stop
            if (year >= 2007)
            {
                start = new DateTime(year, 4, 1, 2, 0, 0);
                end = new DateTime(year, 11, 1, 2, 0, 0);
            }
            else
            {
                start = new DateTime(year, 3, 1, 2, 0, 0);
                end = new DateTime(year, 12, 1, 2, 0, 0);
            }

            // Move forward for the start date until we have a sunday
            while (cal.GetDayOfWeek(start) != DayOfWeek.Sunday)
                start = cal.AddDays(start, 1);

            // Move backwards from the end date to the last sunday
            while (cal.GetDayOfWeek(end) != DayOfWeek.Sunday)
                start = cal.AddDays(end, 1);

            // Create it
            return new DaylightTime(start, end,
                new TimeSpan(stOffset - dtOffset, 0, 0));
        }
开发者ID:DF-thangld,项目名称:web_game,代码行数:33,代码来源:TimeZoneUS.cs

示例2: AddDays

 /// <summary>
 /// Inherited code: Requires comment.
 /// </summary>
 /// <param name="time">Inherited code: Requires comment 1.</param>
 /// <param name="days">Inherited code: Requires comment 2.</param>
 /// <returns>Inherited code: Requires comment 3.</returns>
 public static DateTime? AddDays(DateTime time, int days)
 {
     System.Globalization.Calendar cal = new GregorianCalendar();
     try
     {
         return cal.AddDays(time, days);
     }
     catch (ArgumentException)
     {
         return null;
     }
 }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:18,代码来源:DateTimeHelper.cs

示例3: ParseTrek

        private bool ParseTrek(ClockToken[] dt, ref System.Int32 parsePos, TclDateTime calendar)
        // calendar object to set
        {
            int pos = parsePos;

            if (pos + 3 < dt.Length && dt[pos].is_Renamed(ClockToken.STARDATE) && dt[pos + 1].UNumber && dt[pos + 2].is_Renamed('.') && dt[pos + 3].UNumber)
            {
                GregorianCalendar gcal = new GregorianCalendar();
                int trekYear = dt[pos + 1].Int / 1000 + 2323 - 377;
                int trekDay = 1 + ((dt[pos + 1].Int % 1000) * (gcal.IsLeapYear(trekYear) ? 366 : 365)) / 1000;
                int trekSeconds = dt[pos + 3].Int * 144 * 60;
                calendar.year = trekYear;
                calendar.dateTime = gcal.AddDays(calendar.dateTime, trekDay);
                calendar.second = trekSeconds;
                parsePos = pos + 4;
                return true;
            }
            return false;
        }
开发者ID:BclEx,项目名称:GpuStructs,代码行数:19,代码来源:ClockCmd.cs

示例4: VerifySelectDaySingleRangeMouseHover

        private void VerifySelectDaySingleRangeMouseHover(Calendar calendar)
        {
            //Assumes that the Calendar is Gregorian
            CalendarDayButton b;
            System.Globalization.Calendar cal = new GregorianCalendar();
            int start, end;
            DateTime r1, r2;

            r1 = new DateTime(2003, 10, 10);
            r2 = new DateTime(2003, 11, 1);

            Clear();
            calendar.DisplayDate = r1;
            b = calendar.FindDayButtonFromDay(r1);
            start = b.Index;
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonDown(b, null);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);

            while (DateTime.Compare(r2, r1) > 0)
            {
                r1 = cal.AddDays(r1, 1);
                b = calendar.FindDayButtonFromDay(r1);
                calendar.TestHook.MonthControl.TestHook.Cell_MouseEnter(b, null);
                calendar.TestHook.MonthControl.TestHook.Cell_MouseLeave(b, null);
            }
            end = b.Index;
            Assert.IsTrue(calendar.SelectedDates.Count == 0);

            //check if the buttons are highlighted
            for (int i = start; i <= end; i++)
            {
                Assert.IsTrue(((CalendarDayButton)calendar.TestHook.MonthControl.MonthView.Children[i]).IsSelected);
            }

            b = calendar.FindDayButtonFromDay(r2);
            calendar.TestHook.MonthControl.TestHook.Cell_MouseLeftButtonUp(b, null);

            Assert.IsTrue(_addedDays.Count == 23);
            Assert.IsTrue(_eventCount == 1);

            Assert.IsTrue(DateTimeHelper.CompareYearMonth(calendar.DisplayDate, r2) == 0);
            Assert.IsTrue(calendar.SelectedDates.Count == 23);
            Assert.IsTrue(CompareDates(calendar.SelectedDates[0], calendar.SelectedDate.Value));

            _isLoaded = false;
        }
开发者ID:dfr0,项目名称:moon,代码行数:46,代码来源:CalendarTest.cs

示例5: ProcessUpKey

 private void ProcessUpKey() 
 {
     System.Globalization.Calendar _cal = new GregorianCalendar();
     if (this.DisplayMode == CalendarMode.Month) 
     {
         DateTime selectedDate = _cal.AddDays(this.SelectedDate.GetValueOrDefault(DateTime.Today), -7);
         if (IsValidDate(this, selectedDate)) 
         { 
             OnDayClick(selectedDate);
         } 
     }
     else
     { 
         Debug.Assert(this.DisplayMode == CalendarMode.Year);
         DateTime selectedMonth = _cal.AddMonths(this._selectedMonth, -4);
         OnSelectedMonthChanged(selectedMonth); 
     } 
 }
开发者ID:dfr0,项目名称:moon,代码行数:18,代码来源:Calendar.cs

示例6: ProcessEndKey

 private void ProcessEndKey() 
 { 
     System.Globalization.Calendar _cal = new GregorianCalendar();
     if (this.DisplayMode == CalendarMode.Month) 
     {
         if (this.DisplayDate != null)
         { 
             DateTime selectedDate = new DateTime(((DateTime)this.DisplayDate).Year, ((DateTime)this.DisplayDate).Month, 1);
             selectedDate = _cal.AddMonths(selectedDate, 1);
             selectedDate = _cal.AddDays(selectedDate, -1); 
             if (IsValidDate(this, selectedDate)) 
             {
                 OnDayClick(selectedDate); 
             }
         }
     } 
     else
     {
         Debug.Assert(this.DisplayMode == CalendarMode.Year); 
         DateTime selectedMonth = new DateTime(this._selectedMonth.Year, 12, 1); 
         OnSelectedMonthChanged(selectedMonth);
     } 
 }
开发者ID:dfr0,项目名称:moon,代码行数:23,代码来源:Calendar.cs


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