• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# DataTypes.Date_Time类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Period

 public Period(Date_Time start, TimeSpan duration)
     : this()
 {
     StartTime = start;
     Duration = new Duration(duration);            
     EndTime = start + duration;
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:7,代码来源:Period.cs


示例2: Period

 public Period(DateTime start, DateTime end)
     : this()
 {
     StartTime = new Date_Time(start);
     EndTime = new Date_Time(end);
     Duration = new Duration(start - end);
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:7,代码来源:Period.cs


示例3: TryParse

 public override bool TryParse(string value, ref object obj)
 {
     string[] values = value.Split(',');
     foreach (string v in values)
     {
         object dt = new Date_Time();
         object p = new Period();
         
         //
         // Set the iCalendar for each Date_Time object here,
         // so that any time zones applied to these objects will be
         // handled correctly.
         // NOTE: fixes RRULE30 eval, where EXDATE references a 
         // DATE-TIME without a time zone; therefore, the time zone
         // is implied from DTSTART, and would fail to do a proper
         // time zone lookup, because it wasn't assigned an iCalendar
         // object.
         //
         if (((Date_Time)dt).TryParse(v, ref dt))
         {
             ((Date_Time)dt).iCalendar = iCalendar;
             ((Date_Time)dt).TZID = TZID;
             Items.Add(dt);
         }
         else if (((Period)p).TryParse(v, ref p))
         {
             ((Period)p).StartTime.iCalendar = ((Period)p).EndTime.iCalendar = iCalendar;
             ((Period)p).StartTime.TZID = ((Period)p).EndTime.TZID = TZID;
             Items.Add(p);
         }
         else return false;
     }
     return true;
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:34,代码来源:RDate.cs


示例4: 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


示例5: TestAlarm

        public void TestAlarm(string Calendar, List<Date_Time> Dates, Date_Time Start, Date_Time End)
        {
            iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Alarm\" + Calendar);
            Program.TestCal(iCal);
            Event evt = (Event)iCal.Events[0];

            Start.iCalendar = iCal;
            Start.TZID = tzid;
            End.iCalendar = iCal;
            End.TZID = tzid;

            evt.Evaluate(Start, End);

            for (int i = 0; i < Dates.Count; i++)
            {
                Dates[i].TZID = tzid;
                Dates[i].iCalendar = iCal;
            }

            // Poll all alarms that occurred between Start and End
            List<DDay.iCal.Components.Alarm.AlarmOccurrence> alarms = evt.PollAlarms();

            foreach (DDay.iCal.Components.Alarm.AlarmOccurrence alarm in alarms)
                Assert.IsTrue(Dates.Contains(alarm.DateTime), "Alarm triggers at " + alarm.DateTime + ", but it should not.");
            Assert.IsTrue(Dates.Count == alarms.Count, "There were " + alarms.Count + " alarm occurrences; there should have been " + Dates.Count + ".");
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:26,代码来源:Alarm.cs


示例6: Evaluate

        public override ArrayList Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            if (DTStart != null)
                DateTimes.Add(DTStart);

            return base.Evaluate(FromDate, ToDate);
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:8,代码来源:Todo.cs


示例7: Date_TimeUTCSerializer

        public Date_TimeUTCSerializer(Date_Time dt)
            : base(dt)
        {
            // Make a copy of the Date_Time object, so we don't alter
            // the original
            DateTime = dt.Copy();

            // Set the Date_Time object to UTC time
            DateTime.SetKind(DateTimeKind.Utc);            
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:10,代码来源:Date_TimeUTCSerializer.cs


示例8: Period

 public Period(Date_Time start, Date_Time end)
     : this()
 {
     StartTime = start.Copy();
     if (end != null)
     {
         EndTime = end.Copy();
         Duration = new Duration(end.Value - start.Value);
     }            
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:10,代码来源:Period.cs


示例9: Evaluate

        public override System.Collections.Generic.List<Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            if (Start != null)
            {
                Period p = new Period(Start);
                if (!Periods.Contains(p))
                    Periods.Add(p);

                return base.Evaluate(FromDate, ToDate);
            }
            return new System.Collections.Generic.List<Period>();
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:12,代码来源:Journal.cs


示例10: Date_TimeUTCSerializer

        public Date_TimeUTCSerializer(Date_Time dt)
            : base(dt)
        {
            // Make a copy of the Date_Time object, so we don't alter
            // the original
            DateTime = dt.Copy();

            // Set the Date_Time object to UTC time
            DateTime = DateTime.UTC;

            // Ensure time is serialized
            DateTime.HasTime = true;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:13,代码来源:Date_TimeUTCSerializer.cs


示例11: Date_TimeUTCSerializer

        public Date_TimeUTCSerializer(Date_Time dt)
            : base(dt)
        {
            // Make a copy of the Date_Time object, so we don't alter
            // the original
            DateTime = dt.Copy();

            // Set the Date_Time object to UTC time
            DateTime = DateTime.UTC;

            // FIXME: this is the old way we did it; remove when verified
            //DateTime.SetKind(DateTimeKind.Utc);            
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:13,代码来源:Date_TimeUTCSerializer.cs


示例12: 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


示例13: IsCompleted

 /// <summary>
 /// Use this method to determine if a todo item has been completed.
 /// This takes into account recurrence items and the previous date
 /// of completion, if any.
 /// </summary>
 /// <param name="DateTime">The date and time to test.</param>
 /// <returns>True if the todo item has been completed</returns>
 public bool IsCompleted(Date_Time currDt)
 {
     if (Status == Status.COMPLETED)
     {
         foreach (Date_Time dt in DateTimes)
         {
             if (dt > Completed && // The item has recurred after it was completed
                 currDt > dt)      // and the current date is after the recurrence date.
                 return false;
         }
         return true;
     }
     return false;
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:21,代码来源:Todo.cs


示例14: Evaluate

        public ArrayList Evaluate(Date_Time StartDate, Date_Time FromDate, Date_Time EndDate)
        {
            ArrayList Periods = new ArrayList();

            if (StartDate > FromDate)
                FromDate = StartDate;

            if (EndDate < FromDate ||
                FromDate > EndDate)
                return Periods;
            
            foreach (object obj in Items)
                Periods.Add(obj);                

            return Periods;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:16,代码来源:RDate.cs


示例15: EvaluateRRule

 /// <summary>
 /// Evaulates the RRule component, and adds each specified DateTime
 /// to the <see cref="Periods"/> collection.
 /// </summary>
 /// <param name="FromDate">The beginning date of the range to evaluate.</param>
 /// <param name="ToDate">The end date of the range to evaluate.</param>
 protected void EvaluateRRule(Date_Time FromDate, Date_Time ToDate)
 {
     // Handle RRULEs
     if (RRule != null)
     {
         foreach (Recur rrule in RRule)
         {
             ArrayList DateTimes = rrule.Evaluate(DTStart, FromDate, ToDate);
             foreach (Date_Time dt in DateTimes)
             {                            
                 if (!this.DateTimes.Contains(dt.Value))
                     this.DateTimes.Add(dt.Value);
             }
         }
     }
 }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:22,代码来源:TimeZoneInfo.cs


示例16: TryParse

        public override bool TryParse(string value, ref object obj)
        {
            string[] values = value.Split(',');
            foreach (string v in values)
            {
                object dt = new Date_Time();
                object p = new Period();

                if (((Date_Time)dt).TryParse(v, ref dt))
                    Items.Add(dt);
                else if (((Period)p).TryParse(v, ref p))
                    Items.Add(p);
                else return false;
            }
            return true;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:16,代码来源:RDate.cs


示例17: GetTimeZoneInfo

        /// <summary>
        /// Retrieves the TimeZoneInfo object that contains information
        /// about the TimeZone, with the name of the current timezone,
        /// offset from UTC, etc.
        /// </summary>
        /// <param name="dt">The Date_Time object for which to retrieve the TimeZoneInfo</param>
        /// <returns>A TimeZoneInfo object for the specified Date_Time</returns>
        public TimeZoneInfo GetTimeZoneInfo(Date_Time dt)
        {
            TimeZoneInfo tzi = null;

            TimeSpan mostRecent = TimeSpan.MaxValue;
            foreach (TimeZoneInfo curr in TimeZoneInfos)
            {
                DateTime Start = new DateTime(dt.Year - 1, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                DateTime End = new DateTime(dt.Year + 1, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                
                DateTime dtUTC = dt.Value;
                dtUTC = DateTime.SpecifyKind(dtUTC, DateTimeKind.Utc);

                if (curr.TZOffsetTo != null)
                {
                    int mult = curr.TZOffsetTo.Positive ? -1 : 1;
                    dtUTC = dtUTC.AddHours(curr.TZOffsetTo.Hours * mult);
                    dtUTC = dtUTC.AddMinutes(curr.TZOffsetTo.Minutes * mult);
                    dtUTC = dtUTC.AddSeconds(curr.TZOffsetTo.Seconds * mult);
                    curr.Start = curr.Start.AddHours(curr.TZOffsetTo.Hours * mult);
                    curr.Start = curr.Start.AddMinutes(curr.TZOffsetTo.Minutes * mult);
                    curr.Start = curr.Start.AddSeconds(curr.TZOffsetTo.Seconds * mult);
                }
                                
                // Determine the UTC occurrences of the Time Zone changes
                // FIXME: are these start/end dates correct when TimeZone or UTC time is taken into account?
                if (curr.EvalStart == null ||
                    curr.EvalEnd == null ||
                    dtUTC < curr.EvalStart.Value ||
                    dtUTC > curr.EvalEnd.Value)
                    curr.Evaluate(Start, End);

                foreach (Date_Time currDt in curr.DateTimes)
                {                    
                    TimeSpan currentSpan = dtUTC - currDt;
                    if (currentSpan.Ticks >= 0 &&
                        currentSpan.Ticks < mostRecent.Ticks)
                    {
                        mostRecent = currentSpan;
                        tzi = curr;
                    }
                }
            }

            return tzi;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:53,代码来源:TimeZone.cs


示例18: IsCompleted

        /// <summary>
        /// Use this method to determine if a todo item has been completed.
        /// This takes into account recurrence items and the previous date
        /// of completion, if any.
        /// </summary>
        /// <param name="DateTime">The date and time to test.</param>
        /// <returns>True if the todo item has been completed</returns>
        public bool IsCompleted(Date_Time currDt)
        {
            if (Status == TodoStatus.COMPLETED)
            {
                if (Completed == null)
                    return true;

                foreach (Period p in Periods)
                {
                    if (p.StartTime > Completed && // The item has recurred after it was completed
                        currDt >= p.StartTime)     // and the current date is after or on the recurrence date.
                        return false;
                }
                return true;
            }
            return false;
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:24,代码来源:Todo.cs


示例19: LoadAndDisplayCalendar

        public void LoadAndDisplayCalendar()
        {
             // The following code loads and displays an iCalendar
             // with US Holidays for 2006.
             //
             iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\General\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.TimeZoneName);
                             Console.Write(")");
                         }
 
                         Console.Write(Environment.NewLine);
                     }
                 }
 
                 // Move to the next day
                 dt = dt.AddDays(1);
             }
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:43,代码来源:Program.cs


示例20: DateDiff

        public static long DateDiff(Recur.FrequencyType frequency, Date_Time dt1, Date_Time dt2, DayOfWeek firstDayOfWeek) 
        {
            if (frequency == Recur.FrequencyType.YEARLY) 
                return dt2.Year - dt1.Year;

            if (frequency == Recur.FrequencyType.MONTHLY)
                return (dt2.Month - dt1.Month) + (12 * (dt2.Year - dt1.Year));

            if (frequency == Recur.FrequencyType.WEEKLY)
            {
                // Get the week of year of the time frame we want to calculate
                int firstEvalWeek = _Calendar.GetWeekOfYear(dt2.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, firstDayOfWeek);

                // Count backwards in years, calculating how many weeks' difference we have between
                // first and second dates
                Date_Time evalDate = dt2.Copy();
                while (evalDate.Year > dt1.Year)
                {
                    firstEvalWeek += _Calendar.GetWeekOfYear(new DateTime(evalDate.Year - 1, 12, 31), System.Globalization.CalendarWeekRule.FirstFourDayWeek, firstDayOfWeek);
                    evalDate = evalDate.AddYears(-1);
                }

                // Determine the difference, in weeks, between the start date and the evaluation period.
                int startWeek = _Calendar.GetWeekOfYear(dt1.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, firstDayOfWeek);
                return firstEvalWeek - startWeek;                
            }
 
            TimeSpan ts = dt2 - dt1;

            if (frequency == Recur.FrequencyType.DAILY) 
                return Round(ts.TotalDays);

            if (frequency == Recur.FrequencyType.HOURLY) 
                return Round(ts.TotalHours);

            if (frequency == Recur.FrequencyType.MINUTELY) 
                return Round(ts.TotalMinutes);

            if (frequency == Recur.FrequencyType.SECONDLY) 
                return Round(ts.TotalSeconds); 
 
            return 0;  
        }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:43,代码来源:DateUtils.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# DataTypes.iCalDateTime类代码示例发布时间:2022-05-24
下一篇:
C# Components.iCalObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap