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


C# iCalDateTime类代码示例

本文整理汇总了C#中iCalDateTime的典型用法代码示例。如果您正苦于以下问题:C# iCalDateTime类的具体用法?C# iCalDateTime怎么用?C# iCalDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ShowCalendar

        /// <summary>
        /// Displays the calendar in the time zone identified by <paramref name="tzid"/>.
        /// </summary>
        static void ShowCalendar(iCalendar iCal, string tzid)
        {
            iCalDateTime start = new iCalDateTime(2007, 3, 1);
            iCalDateTime end = new iCalDateTime(2007, 4, 1).AddSeconds(-1);

            List<Occurrence> occurrences = iCal.GetOccurrences(start, end);

            Console.WriteLine("====Events/Todos/Journal Entries in " + tzid + "====");
            foreach (Occurrence o in occurrences)
            {
                Console.WriteLine(
                    o.Period.StartTime.ToTimeZone(tzid).ToString("ddd, MMM d - h:mm") + " to " +
                    o.Period.EndTime.ToTimeZone(tzid).ToString("h:mm tt") + Environment.NewLine +
                    o.Component.Summary + Environment.NewLine);
            }

            Console.WriteLine("====Alarms in " + tzid + "====");
            foreach (RecurringComponent rc in iCal.RecurringComponents)
            {
                foreach (AlarmOccurrence ao in rc.PollAlarms(start, end))
                {
                    Console.WriteLine(
                        "Alarm: " +
                        ao.DateTime.ToTimeZone(tzid).ToString("ddd, MMM d - h:mm") + ": " +
                        ao.Alarm.Summary);
                }
            }

            Console.WriteLine();
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:33,代码来源:Program.cs

示例2: YearlyComplex1

        public void YearlyComplex1()
        {
            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\YearlyComplex1.ics")[0];
            ProgramTest.TestCal(iCal);
            IEvent evt = iCal.Events[0];
            IList<Occurrence> occurrences = evt.GetOccurrences(
                new iCalDateTime(2006, 1, 1, tzid),
                new iCalDateTime(2011, 1, 1, tzid));

            IDateTime dt = new iCalDateTime(2007, 1, 1, 8, 30, 0, tzid);
            int i = 0;

            while (dt.Year < 2011)
            {
                if ((dt.GreaterThan(evt.Start)) &&
                    (dt.Year % 2 == 1) && // Every-other year from 2005
                    (dt.Month == 1) &&
                    (dt.DayOfWeek == DayOfWeek.Sunday))
                {
                    IDateTime 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,代码来源:RecurrenceTest.cs

示例3: TestAlarm

        public void TestAlarm(string calendar, List<IDateTime> dates, iCalDateTime start, iCalDateTime end)
        {
            IICalendar iCal = iCalendar.LoadFromFile(@"Calendars/Alarm/" + calendar)[0];
            ProgramTest.TestCal(iCal);
            IEvent evt = iCal.Events.First();
            
            // Poll all alarms that occurred between Start and End
            IList<AlarmOccurrence> alarms = evt.PollAlarms(start, end);

            foreach (AlarmOccurrence alarm in alarms)
                Assert.IsTrue(dates.Contains(alarm.DateTime), "Alarm triggers at " + alarm.Period.StartTime + ", but it should not.");
            Assert.IsTrue(dates.Count == alarms.Count, "There were " + alarms.Count + " alarm occurrences; there should have been " + dates.Count + ".");
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:13,代码来源:AlarmTest.cs

示例4: Bug3191956

        public void Bug3191956()
        {
            var queue = new Queue<iCalDateTime>();
            for (int i = 0; i < 4; i++)
            {
                var dateTime = new iCalDateTime(2011, 1, 1);
                dateTime.HasTime = false;
                queue.Enqueue(dateTime);
            }

            IDateTime dt = queue.Dequeue();
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddHours(0);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddHours(24);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddHours(1);
            Assert.IsTrue(dt.HasTime);

            dt = queue.Dequeue();
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMinutes(0);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMinutes(1440);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMinutes(1);
            Assert.IsTrue(dt.HasTime);

            dt = queue.Dequeue();
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddSeconds(0);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddSeconds(86400);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddSeconds(1);
            Assert.IsTrue(dt.HasTime);

            dt = queue.Dequeue();
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMilliseconds(0);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMilliseconds(86400000);
            Assert.IsFalse(dt.HasTime);
            dt = dt.AddMilliseconds(1);
            Assert.IsTrue(dt.HasTime);
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:46,代码来源:iCalDateTimeTest.cs

示例5: Test3

        public void Test3()
        {
            IICalendar iCal = new iCalendar();
            IEvent evt = iCal.Create<Event>();

            evt.Start = new iCalDateTime(2008, 10, 18, 10, 30, 0);
            evt.Summary = "Test Event";
            evt.Duration = TimeSpan.FromHours(1);
            evt.RecurrenceRules.Add(new RecurrencePattern("RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH"));

            IDateTime doomsdayDate = new iCalDateTime(2010, 12, 31, 10, 30, 0);
            IList<Occurrence> allOcc = evt.GetOccurrences(evt.Start, doomsdayDate);

            foreach (Occurrence occ in allOcc)
                Console.WriteLine(occ.Period.StartTime.ToString("d") + " " + occ.Period.StartTime.ToString("t"));
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:16,代码来源:RecurrenceTest.cs

示例6: RecurrencePattern2

        public void RecurrencePattern2()
        {
            // NOTE: evaluators are generally not meant to be used directly like this.
            // However, this does make a good test to ensure they behave as they should.
            RecurrencePattern pattern = new RecurrencePattern("FREQ=MINUTELY;INTERVAL=1");

            CultureInfo us = CultureInfo.CreateSpecificCulture("en-US");

            iCalDateTime startDate = new iCalDateTime(DateTime.Parse("3/31/2008 12:00:10 AM", us));
            iCalDateTime fromDate = new iCalDateTime(DateTime.Parse("4/1/2008 10:08:10 AM", us));
            iCalDateTime toDate = new iCalDateTime(DateTime.Parse("4/1/2008 10:43:23 AM", us));

            IEvaluator evaluator = pattern.GetService(typeof(IEvaluator)) as IEvaluator;
            Assert.IsNotNull(evaluator);

            IList<IPeriod> occurrences = evaluator.Evaluate(
                startDate, 
                DateUtil.SimpleDateTimeToMatch(fromDate, startDate), 
                DateUtil.SimpleDateTimeToMatch(toDate, startDate),
                false);
            Assert.AreNotEqual(0, occurrences.Count);
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:22,代码来源:RecurrenceTest.cs

示例7: GetOccurrences1

        public void GetOccurrences1()
        {
            IICalendar iCal = new iCalendar();
            IEvent evt = iCal.Create<Event>();
            evt.Start = new iCalDateTime(2009, 11, 18, 5, 0, 0);
            evt.End = new iCalDateTime(2009, 11, 18, 5, 10, 0);
            evt.RecurrenceRules.Add(new RecurrencePattern(FrequencyType.Daily));
            evt.Summary = "xxxxxxxxxxxxx";
 
            iCalDateTime previousDateAndTime = new iCalDateTime(2009, 11, 17, 0, 15, 0);
            iCalDateTime previousDateOnly = new iCalDateTime(2009, 11, 17, 23, 15, 0);
            iCalDateTime laterDateOnly = new iCalDateTime(2009, 11, 19, 3, 15, 0);
            iCalDateTime laterDateAndTime = new iCalDateTime(2009, 11, 19, 11, 0, 0);
            iCalDateTime end = new iCalDateTime(2009, 11, 23, 0, 0, 0);

            IList<Occurrence> occurrences = null;

            occurrences = evt.GetOccurrences(previousDateAndTime, end);
            Assert.AreEqual(5, occurrences.Count);

            occurrences = evt.GetOccurrences(previousDateOnly, end);
            Assert.AreEqual(5, occurrences.Count);

            occurrences = evt.GetOccurrences(laterDateOnly, end);
            Assert.AreEqual(4, occurrences.Count);

            occurrences = evt.GetOccurrences(laterDateAndTime, end);
            Assert.AreEqual(3, occurrences.Count);

            // Add ByHour "9" and "12"            
            evt.RecurrenceRules[0].ByHour.Add(9);
            evt.RecurrenceRules[0].ByHour.Add(12);

            // Clear the evaluation so we can calculate recurrences again.
            evt.ClearEvaluation();

            occurrences = evt.GetOccurrences(previousDateAndTime, end);
            Assert.AreEqual(11, occurrences.Count);

            occurrences = evt.GetOccurrences(previousDateOnly, end);
            Assert.AreEqual(11, occurrences.Count);

            occurrences = evt.GetOccurrences(laterDateOnly, end);
            Assert.AreEqual(8, occurrences.Count);

            occurrences = evt.GetOccurrences(laterDateAndTime, end);
            Assert.AreEqual(7, occurrences.Count);
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:48,代码来源:RecurrenceTest.cs

示例8: RECURPARSE6

        public void RECURPARSE6()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event";
            evt.Start = new iCalDateTime(2006, 1, 1, 9, 0, 0);
            evt.Duration = new TimeSpan(1, 0, 0);
            evt.RecurrenceRules.Add(new RecurrencePattern("Every month on the first sunday, at 5:00PM, and at 7:00PM"));

            IList<Occurrence> occurrences = evt.GetOccurrences(
                new iCalDateTime(2006, 1, 1),
                new iCalDateTime(2006, 3, 31));

            iCalDateTime[] DateTimes = new iCalDateTime[]
            {
                new iCalDateTime(2006, 1, 1, 9, 0, 0),
                new iCalDateTime(2006, 1, 1, 17, 0, 0),
                new iCalDateTime(2006, 1, 1, 19, 0, 0),
                new iCalDateTime(2006, 2, 5, 17, 0, 0),
                new iCalDateTime(2006, 2, 5, 19, 0, 0),
                new iCalDateTime(2006, 3, 5, 17, 0, 0),
                new iCalDateTime(2006, 3, 5, 19, 0, 0)
            };

            for (int i = 0; i < DateTimes.Length; i++)
                Assert.AreEqual(DateTimes[i], occurrences[i].Period.StartTime, "Event should occur on " + DateTimes[i]);

            Assert.AreEqual(
                DateTimes.Length,
                occurrences.Count,
                "There should be exactly " + DateTimes.Length +
                " occurrences; there were " + occurrences.Count);
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:34,代码来源:RecurrenceTest.cs

示例9: RecurrencePattern1

        public void RecurrencePattern1()
        {
            // NOTE: evaluators are not generally meant to be used directly like this.
            // However, this does make a good test to ensure they behave as they should.
            IRecurrencePattern pattern = new RecurrencePattern("FREQ=SECONDLY;INTERVAL=10");
            pattern.RestrictionType = RecurrenceRestrictionType.NoRestriction;

            CultureInfo us = CultureInfo.CreateSpecificCulture("en-US");

            iCalDateTime startDate = new iCalDateTime(DateTime.Parse("3/30/08 11:59:40 PM", us));
            iCalDateTime fromDate = new iCalDateTime(DateTime.Parse("3/30/08 11:59:40 PM", us));
            iCalDateTime toDate = new iCalDateTime(DateTime.Parse("3/31/08 12:00:11 AM", us));

            IEvaluator evaluator = pattern.GetService(typeof(IEvaluator)) as IEvaluator;
            Assert.IsNotNull(evaluator);

            IList<IPeriod> occurrences = evaluator.Evaluate(
                startDate, 
                DateUtil.SimpleDateTimeToMatch(fromDate, startDate), 
                DateUtil.SimpleDateTimeToMatch(toDate, startDate),
                false);
            Assert.AreEqual(4, occurrences.Count);
            Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/30/08 11:59:40 PM", us)), occurrences[0].StartTime);
            Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/30/08 11:59:50 PM", us)), occurrences[1].StartTime);
            Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/31/08 12:00:00 AM", us)), occurrences[2].StartTime);
            Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/31/08 12:00:10 AM", us)), occurrences[3].StartTime);
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:27,代码来源:RecurrenceTest.cs

示例10: Bug3312618and3522651

        public void Bug3312618and3522651()
        {
            IICalendar calendar = iCalendar.LoadFromFile(@"Calendars/Recurrence/Bug3312618and3522651.ics").First();
            iCalDateTime from = new iCalDateTime(2010, 1, 1, true);
            iCalDateTime to = new iCalDateTime(2011, 12, 31, true);

            var occurrences = calendar.GetOccurrences(from, to);
            Assert.AreEqual(1, occurrences.Count);
            Assert.AreEqual(0, occurrences[0].Period.Duration.Ticks);
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:10,代码来源:RecurrenceTest.cs

示例11: RECURPARSE5

        public void RECURPARSE5()
        {
            iCalendar iCal = new iCalendar();

            Event evt = iCal.Create<Event>();
            evt.Summary = "Test event";
            evt.Start = new iCalDateTime(2006, 1, 1, 9, 0, 0);
            evt.Duration = new TimeSpan(1, 0, 0);
            evt.RecurrenceRules.Add(new RecurrencePattern("Every 10 minutes until 1/1/2006 9:50"));

            IList<Occurrence> occurrences = evt.GetOccurrences(
                new iCalDateTime(2006, 1, 1),
                new iCalDateTime(2006, 1, 31));

            iCalDateTime[] DateTimes = new iCalDateTime[]
            {
                new iCalDateTime(2006, 1, 1, 9, 0, 0),
                new iCalDateTime(2006, 1, 1, 9, 10, 0),
                new iCalDateTime(2006, 1, 1, 9, 20, 0),
                new iCalDateTime(2006, 1, 1, 9, 30, 0),
                new iCalDateTime(2006, 1, 1, 9, 40, 0),
                new iCalDateTime(2006, 1, 1, 9, 50, 0)
            };

            for (int i = 0; i < DateTimes.Length; i++)
                Assert.AreEqual(DateTimes[i], occurrences[i].Period.StartTime, "Event should occur on " + DateTimes[i]);

            Assert.AreEqual(
                DateTimes.Length,
                occurrences.Count,
                "There should be exactly " + DateTimes.Length +
                " occurrences; there were " + occurrences.Count);
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:33,代码来源:RecurrenceTest.cs

示例12: Bug3312619

        public void Bug3312619()
        {
            IICalendar calendar = iCalendar.LoadFromFile(@"Calendars/Recurrence/Bug3312619.ics").First();
            iCalDateTime from = new iCalDateTime(2011, 6, 1) { HasTime = true };
            iCalDateTime to = new iCalDateTime(2012, 7, 1) { HasTime = true };

            var occurrences = calendar.GetOccurrences(from, to);
            Assert.AreEqual(59, occurrences.Count);
        }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:9,代码来源:RecurrenceTest.cs

示例13: GetOccurrences

        /// <summary>
        /// Gets the occurrences.
        /// </summary>
        /// <param name="startTime">The start time.</param>
        /// <param name="endTime">The end time.</param>
        /// <remarks> Вычисляет все экземпляры рекурсивного события в соотв с паттерном рекурсии. С учетом exception event.
        /// </remarks>
        /// <returns></returns>
        public override List<Occurrence> GetOccurrences(iCalDateTime startTime, iCalDateTime endTime)
        {
            //Очищаем кеш повторений
            ClearEvaluation();

            List<Occurrence> retVal = base.GetOccurrences(startTime, endTime);

            if(RecurrenceException != null)
            {
                foreach (McEvent exception in RecurrenceException)
                {
                    if (exception.Recurrence_ID != null)
                    {
                        //Start = RecurrenceId, Duration = Parent event duration
                        Occurrence exceptionOccur = new Occurrence(null, new Period(exception.Recurrence_ID, this.Duration));
                        //remove exception from orig occurrences list
                        if (retVal.Contains(exceptionOccur))
                        {
                            retVal.Remove(exceptionOccur);
                        }
                    }
                }
            }
            return retVal;
        }
开发者ID:0anion0,项目名称:IBN,代码行数:33,代码来源:McEvent.cs

示例14: Bug3354307

 public void Bug3354307()
 {
     var now = DateTime.Now;
     var dt = new iCalDateTime(now);
     Assert.AreEqual(dt, (object)now);
 }
开发者ID:nachocove,项目名称:DDay-iCal-Xamarin,代码行数:6,代码来源:SerializationTest.cs

示例15: Test4

        public void Test4()
        {
            IRecurrencePattern rpattern = new RecurrencePattern();
            rpattern.ByDay.Add(new WeekDay(DayOfWeek.Saturday));
            rpattern.ByDay.Add(new WeekDay(DayOfWeek.Sunday));

            rpattern.Frequency = FrequencyType.Weekly;

            IDateTime evtStart = new iCalDateTime(2006, 12, 1);
            IDateTime evtEnd = new iCalDateTime(2007, 1, 1);

            IEvaluator evaluator = rpattern.GetService(typeof(IEvaluator)) as IEvaluator;
            Assert.IsNotNull(evaluator);

            // Add the exception dates
            IList<IPeriod> periods = evaluator.Evaluate(
                evtStart,
                DateUtil.GetSimpleDateTimeData(evtStart), 
                DateUtil.SimpleDateTimeToMatch(evtEnd, evtStart),
                false);
            Assert.AreEqual(10, periods.Count);
            Assert.AreEqual(2, periods[0].StartTime.Day);
            Assert.AreEqual(3, periods[1].StartTime.Day);
            Assert.AreEqual(9, periods[2].StartTime.Day);
            Assert.AreEqual(10, periods[3].StartTime.Day);
            Assert.AreEqual(16, periods[4].StartTime.Day);
            Assert.AreEqual(17, periods[5].StartTime.Day);
            Assert.AreEqual(23, periods[6].StartTime.Day);
            Assert.AreEqual(24, periods[7].StartTime.Day);
            Assert.AreEqual(30, periods[8].StartTime.Day);
            Assert.AreEqual(31, periods[9].StartTime.Day);
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:32,代码来源:RecurrenceTest.cs


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