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


C# IDateTime.Copy方法代码示例

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


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

示例1: EvaluateRRule

 /// <summary>
 /// Evaulates the RRule component, and adds each specified Period
 /// 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>
 virtual protected void EvaluateRRule(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
 {
     // Handle RRULEs
     if (Recurrable.RecurrenceRules != null &&
         Recurrable.RecurrenceRules.Count > 0)
     {
         foreach (IRecurrencePattern rrule in Recurrable.RecurrenceRules)
         {
             IEvaluator evaluator = rrule.GetService(typeof(IEvaluator)) as IEvaluator;
             if (evaluator != null)
             {
                 IList<IPeriod> periods = evaluator.Evaluate(referenceDate, periodStart, periodEnd, includeReferenceDateInResults);
                 foreach (IPeriod p in periods)
                 {
                     if (!Periods.Contains(p))
                         Periods.Add(p);
                 }
             }
         }
     }
     else if (includeReferenceDateInResults)
     {
         // If no RRULEs were found, then we still need to add
         // the initial reference date to the results.
         IPeriod p = new Period(referenceDate.Copy<IDateTime>());
         if (!Periods.Contains(p))
             Periods.Add(p);
     }
 }
开发者ID:logikonline,项目名称:DDay.iCal,代码行数:35,代码来源:RecurringEvaluator.cs

示例2: EvaluateToPreviousOccurrence

        public void EvaluateToPreviousOccurrence(IDateTime completedDate, IDateTime currDt)
        {
            IDateTime beginningDate = completedDate.Copy<IDateTime>();

            if (Todo.RecurrenceRules != null)
            {
                foreach (IRecurrencePattern rrule in Todo.RecurrenceRules)
                    DetermineStartingRecurrence(rrule, ref beginningDate);
            }
            if (Todo.RecurrenceDates != null)
            {
                foreach (IPeriodList rdate in Todo.RecurrenceDates)
                    DetermineStartingRecurrence(rdate, ref beginningDate);
            }
            if (Todo.ExceptionRules != null)
            {
                foreach (IRecurrencePattern exrule in Todo.ExceptionRules)
                    DetermineStartingRecurrence(exrule, ref beginningDate);
            }
            if (Todo.ExceptionDates != null)
            {
                foreach (IPeriodList exdate in Todo.ExceptionDates)
                    DetermineStartingRecurrence(exdate, ref beginningDate);
            }

            Evaluate(Todo.Start, DateUtil.GetSimpleDateTimeData(beginningDate), DateUtil.GetSimpleDateTimeData(currDt).AddTicks(1), true);
        }
开发者ID:SpivEgin,项目名称:ndef-nfc,代码行数:27,代码来源:TodoEvaluator.cs

示例3: MatchTimeZone

        public static IDateTime MatchTimeZone(IDateTime dt1, IDateTime dt2)
        {
            Debug.Assert(dt1 != null && dt2 != null);

            // Associate the date/time with the first.
            IDateTime copy = dt2.Copy<IDateTime>();
            copy.AssociateWith(dt1);

            // If the dt1 time does not occur in the same time zone as the
            // dt2 time, then let's convert it so they can be used in the
            // same context (i.e. evaluation).
            if (dt1.TZID != null)
            {
                if (!string.Equals(dt1.TZID, copy.TZID))
                    return (dt1.TimeZoneObservance != null) ? copy.ToTimeZone(dt1.TimeZoneObservance.Value) : copy.ToTimeZone(dt1.TZID);
                else return copy;
            }
            else if (dt1.IsUniversalTime)
            {
                // The first date/time is in UTC time, convert!
                return new iCalDateTime(copy.UTC);
            }
            else
            {
                // The first date/time is in local time, convert!
                return new iCalDateTime(copy.Local);
            }
        }
开发者ID:SpivEgin,项目名称:ndef-nfc,代码行数:28,代码来源:DateUtil.cs


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