本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}