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


C# Date_Time.AddDays方法代码示例

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


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

示例1: AddFrequency

 public static Date_Time AddFrequency(Recur.FrequencyType frequency, Date_Time dt, int interval)
 {
     switch (frequency)
     {
         case Recur.FrequencyType.YEARLY: return dt.AddYears(interval);
         case Recur.FrequencyType.MONTHLY: return dt.AddMonths(interval);
         case Recur.FrequencyType.WEEKLY: return dt.AddDays(interval * 7);
         case Recur.FrequencyType.DAILY: return dt.AddDays(interval);
         case Recur.FrequencyType.HOURLY: return dt.AddHours(interval);
         case Recur.FrequencyType.MINUTELY: return dt.AddMinutes(interval);
         case Recur.FrequencyType.SECONDLY: return dt.AddSeconds(interval);
         default: return dt;
     }
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:14,代码来源:DateUtils.cs

示例2: RRULE1

        public void RRULE1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE1.ics");
            Program.TestCal(iCal);
            Event evt = iCal.Events[0];
            List<Occurrence> occurrences = evt.GetOccurrences(
                new Date_Time(2006, 1, 1, tzid, iCal),
                new Date_Time(2011, 1, 1, tzid, iCal));

            Date_Time dt = new Date_Time(2006, 1, 1, 8, 30, 0, tzid, iCal);
            int i = 0;

            while (dt.Year < 2011)
            {
                if ((dt > evt.Start) &&
                    (dt.Year % 2 == 1) && // Every-other year from 2005
                    (dt.Month == 1) &&
                    (dt.DayOfWeek == DayOfWeek.Sunday))
                {
                    Date_Time dt1 = dt.AddHours(1);
                    Assert.AreEqual(dt, occurrences[i].Period.StartTime, "Event should occur at " + dt);
                    Assert.AreEqual(dt1, occurrences[i + 1].Period.StartTime, "Event should occur at " + dt);
                    i += 2;
                }                

                dt = dt.AddDays(1);
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:28,代码来源:Recurrence.cs

示例3: LoadAndDisplayCalendar

        public void LoadAndDisplayCalendar()
        {            
             // The following code loads and displays an iCalendar 
             // with US Holidays for 2006.
             //
             iCalendar iCal = iCalendar.LoadFromUri(new Uri("http://www.applegatehomecare.com/Calendars/USHolidays.ics"));
             Assert.IsNotNull(iCal, "iCalendar did not load.  Are you connected to the internet?");
             iCal.Evaluate(
                 new Date_Time(2006, 1, 1, "US-Eastern", iCal),
                 new Date_Time(2006, 12, 31, "US-Eastern", iCal));
 
             Date_Time dt = new Date_Time(2006, 1, 1, "US-Eastern", iCal);
             while (dt.Year == 2006)
             {
                 // First, display the current date we're evaluating
                 Console.WriteLine(dt.Local.ToShortDateString());
 
                 // Then, iterate through each event in our iCalendar
                 foreach (Event evt in iCal.Events)
                 {
                     // Determine if the event occurs on the specified date
                     if (evt.OccursOn(dt))
                     {
                         // Display the event summary
                         Console.Write("\t" + evt.Summary);
 
                         // Display the time the event happens (unless it's an all-day event)
                         if (evt.Start.HasTime)
                         {
                             Console.Write(" (" + evt.Start.Local.ToShortTimeString() + " - " + evt.End.Local.ToShortTimeString());
                             if (evt.Start.TimeZoneInfo != null)
                                 Console.Write(" " + evt.Start.TimeZoneInfo.Name);
                             Console.Write(")");
                         }
 
                         Console.Write(Environment.NewLine);
                     }
                 }
 
                 // Move to the next day
                 dt = dt.AddDays(1);
             }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:43,代码来源:Program.cs

示例4: RRULE6

        public void RRULE6()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE6.ics");
            Program.TestCal(iCal);
            Event evt = iCal.Events[0];

            List<Occurrence> occurrences = evt.GetOccurrences(
                new Date_Time(1998, 1, 1, tzid, iCal), 
                new Date_Time(2000, 12, 31, tzid, iCal));

            Date_Time dt = new Date_Time(1998, 1, 1, 9, 0, 0, tzid, iCal);
            int i = 0;
            while (dt.Year < 2001)
            {
                if (dt >= evt.Start &&
                    dt.Month == 1 &&
                    dt <= new Date_Time(2000, 1, 31, 9, 0, 0, tzid, iCal))
                {
                    Assert.AreEqual(dt, occurrences[i].Period.StartTime, "Event should occur at " + dt);
                    i++;
                }

                dt = dt.AddDays(1);
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:25,代码来源:Recurrence.cs

示例5: RRULE3

        public void RRULE3()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE3.ics");
            Program.TestCal(iCal);
            Event evt = iCal.Events[0];

            List<Occurrence> occurrences = evt.GetOccurrences(
                new Date_Time(1997, 9, 1, tzid, iCal),
                new Date_Time(1998, 1, 1, tzid, iCal));

            Date_Time dt = new Date_Time(1997, 9, 2, 9, 0, 0, tzid, iCal);
            int i = 0;
            while (dt.Year < 1998)
            {
                if ((dt >= evt.Start) &&
                    (dt < new Date_Time(1997, 12, 24, 0, 0, 0, tzid, iCal)))
                {
                    Assert.AreEqual(dt, occurrences[i].Period.StartTime, "Event should occur at " + dt);
                    Assert.IsTrue(
                        (dt < new Date_Time(1997, 10, 26, tzid, iCal) && dt.TimeZoneInfo.TimeZoneName == "EDT") ||
                        (dt > new Date_Time(1997, 10, 26, tzid, iCal) && dt.TimeZoneInfo.TimeZoneName == "EST"),
                        "Event " + dt + " doesn't occur in the correct time zone (including Daylight & Standard time zones)");
                    i++;
                }                

                dt = dt.AddDays(1);
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:28,代码来源:Recurrence.cs

示例6: RRULE1

        public void RRULE1()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE1.ics");
            Program.TestCal(iCal);
            Event evt = iCal.Events[0];
            evt.Evaluate(new Date_Time(2006, 1, 1, tzid, iCal), new Date_Time(2011, 1, 1, tzid, iCal));

            Date_Time dt = new Date_Time(2006, 1, 1, 8, 30, 0, tzid, iCal);
            while (dt.Year < 2011)
            {
                if ((dt > evt.Start) &&
                    (dt.Year % 2 == 0) &&
                    (dt.Month == 1) &&
                    (dt.DayOfWeek == DayOfWeek.Sunday))
                {
                    Date_Time dt1 = dt.AddHours(1);
                    Assert.IsTrue(evt.OccursAt(dt), "Event should occur at " + dt);
                    Assert.IsTrue(evt.OccursAt(dt1), "Event should occur at " + dt1);
                }
                else if (dt.Date != evt.Start.Date)
                    Assert.IsFalse(evt.OccursOn(dt), "Event should not occur on " + dt.Local.ToShortDateString());

                dt = dt.AddDays(1);
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:25,代码来源:Recurrence.cs

示例7: RRULE6

        public void RRULE6()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE6.ics");
            Program.TestCal(iCal);
            Event evt = iCal.Events[0];
            evt.Evaluate(new Date_Time(1997, 9, 1, tzid, iCal), new Date_Time(2000, 12, 31, tzid, iCal));

            Date_Time dt = new Date_Time(1998, 1, 1, 9, 0, 0, tzid, iCal);
            while (dt.Year < 2001)
            {
                if (dt >= evt.Start &&
                    dt.Month == 1 &&
                    dt <= new Date_Time(2000, 1, 31, 9, 0, 0, tzid, iCal))
                    Assert.IsTrue(evt.OccursAt(dt), "Event should occur at " + dt);
                else Assert.IsFalse(evt.OccursAt(dt), "Event should not occur at " + dt);

                dt = dt.AddDays(1);
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:19,代码来源:Recurrence.cs

示例8: RRULE3

        public void RRULE3()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE3.ics");
            Program.TestCal(iCal);
            Event evt = iCal.Events[0];
            evt.Evaluate(new Date_Time(1997, 9, 1, tzid, iCal), new Date_Time(1998, 1, 1, tzid, iCal));

            Date_Time dt = new Date_Time(1997, 9, 2, 9, 0, 0, tzid, iCal);
            while (dt.Year < 1998)
            {
                if ((dt >= evt.Start) &&
                    (dt < new Date_Time(1997, 12, 24, 0, 0, 0, tzid, iCal)))
                {
                    Assert.IsTrue(evt.OccursAt(dt), "Event should occur at " + dt);
                    Assert.IsTrue(
                        (dt < new Date_Time(1997, 10, 26, tzid, iCal) && dt.TimeZoneInfo.TimeZoneName == "EDT") ||
                        (dt > new Date_Time(1997, 10, 26, tzid, iCal) && dt.TimeZoneInfo.TimeZoneName == "EST"),
                        "Event " + dt + " doesn't occur in the correct time zone (including Daylight & Standard time zones)");
                }
                else Assert.IsFalse(evt.OccursAt(dt), "Event should not occur at " + dt);

                dt = dt.AddDays(1);
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:24,代码来源:Recurrence.cs

示例9: RRULE6

        public void RRULE6()
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\RRULE6.ics");
            TestCal(iCal);
            Event evt = (Event)iCal.Events[0];
            evt.Evaluate(new Date_Time(1997, 9, 1, tzid, iCal), new Date_Time(2000, 12, 31, tzid, iCal));

            // FIXME: this fails due to the difference in UTC and floating time (since TimeZone's aren't implemented,
            // the DTSTART is treated as floating.  When TimeZones are implemented, this rule should function.
            Date_Time dt = new Date_Time(1998, 1, 1, 9, 0, 0, tzid, iCal);
            while (dt.Year < 2001)
            {
                if (dt >= evt.Start &&
                    dt.Month == 1 &&
                    dt <= new Date_Time(2000, 1, 31, 9, 0, 0, tzid, iCal))
                    Assert.IsTrue(evt.OccursAt(dt), "Event should occur at " + dt);
                else Assert.IsFalse(evt.OccursAt(dt), "Event should not occur at " + dt);

                dt = dt.AddDays(1);
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:21,代码来源:Program.cs

示例10: LoadAndDisplayCalendar

        public void LoadAndDisplayCalendar()
        {   
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars/USHolidays.ics");

            foreach (Event evt in iCal.Events)
                evt.Evaluate(new Date_Time(2006, 1, 1, "/mozilla.org/20050126_1/America/Boise", iCal), new Date_Time(2006, 12, 31, "/mozilla.org/20050126_1/America/Boise", iCal));

            Date_Time dt = new Date_Time(2006, 1, 1, "/mozilla.org/20050126_1/America/Boise", iCal);
            while (dt.Year == 2006)
            {
                Console.WriteLine(dt.Local.ToShortDateString());
                foreach (Event evt in iCal.Events)
                {
                    if (evt.OccursOn(dt))
                        Console.WriteLine("\t" + evt.Summary + (evt.DTStart.HasTime ? " (" + evt.DTStart.Local.ToShortTimeString() + " - " + evt.DTEnd.Local.ToShortTimeString() + " " + (evt.DTStart.TimeZoneInfo != null ? evt.DTStart.TimeZoneInfo.TZName[0] : "") + ")" : ""));
                }

                dt = dt.AddDays(1);
            }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:20,代码来源:Program.cs


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