本文整理汇总了C#中DDay.iCal.DataTypes.iCalDateTime.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# iCalDateTime.Copy方法的具体用法?C# iCalDateTime.Copy怎么用?C# iCalDateTime.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DDay.iCal.DataTypes.iCalDateTime
的用法示例。
在下文中一共展示了iCalDateTime.Copy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Period
public Period(iCalDateTime start, TimeSpan duration)
: this()
{
StartTime = start.Copy();
if (duration != TimeSpan.MinValue)
{
Duration = new Duration(duration);
EndTime = start + duration;
}
}
示例2: iCalDateTimeUTCSerializer
public iCalDateTimeUTCSerializer(iCalDateTime dt)
: base(dt)
{
// Make a copy of the iCalDateTime object, so we don't alter
// the original
DateTime = dt.Copy();
// Set the iCalDateTime object to UTC time
DateTime = DateTime.UTC;
// Ensure time is serialized
DateTime.HasTime = true;
}
示例3: Evaluate
public List<iCalDateTime> Evaluate(iCalDateTime StartDate, iCalDateTime FromDate, iCalDateTime ToDate)
{
List<iCalDateTime> DateTimes = new List<iCalDateTime>();
DateTimes.AddRange(StaticOccurrences);
// Create a temporary recurrence for populating
// missing information using the 'StartDate'.
RecurrencePattern r = new RecurrencePattern();
r.CopyFrom(this);
// Enforce evaluation engine rules
r.EnforceEvaluationRestrictions();
// Fill in missing, necessary ByXXX values
r.EnsureByXXXValues(StartDate);
// Get the occurrences
foreach (iCalDateTime occurrence in r.GetOccurrences(StartDate, FromDate.Copy(), ToDate.Copy(), r.Count))
{
// NOTE:
// Used to be DateTimes.AddRange(r.GetOccurrences(FromDate.Copy(), ToDate, r.Count))
// By doing it this way, fixes bug #19.
if (!DateTimes.Contains(occurrence))
DateTimes.Add(occurrence);
}
// Limit the count of returned recurrences
if (Count != int.MinValue &&
DateTimes.Count > Count)
DateTimes.RemoveRange(Count, DateTimes.Count - Count);
// Process the UNTIL, and make sure the DateTimes
// occur between FromDate and ToDate
for (int i = DateTimes.Count - 1; i >= 0; i--)
{
iCalDateTime dt = (iCalDateTime)DateTimes[i];
if (dt > ToDate ||
dt < FromDate)
DateTimes.RemoveAt(i);
}
// Assign missing values
foreach (iCalDateTime dt in DateTimes)
dt.MergeWith(StartDate);
// Ensure that DateTimes have an assigned time if they occur less than daily
foreach (iCalDateTime dt in DateTimes)
{
if (Frequency < FrequencyType.Daily)
dt.HasTime = true;
}
return DateTimes;
}
示例4: IncrementDate
public void IncrementDate(ref iCalDateTime dt, int Interval)
{
iCalDateTime old = dt.Copy();
switch (Frequency)
{
case FrequencyType.Secondly: dt = old.AddSeconds(Interval); break;
case FrequencyType.Minutely: dt = old.AddMinutes(Interval); break;
case FrequencyType.Hourly: dt = old.AddHours(Interval); break;
case FrequencyType.Daily: dt = old.AddDays(Interval); break;
case FrequencyType.Weekly:
// How the week increments depends on the WKST indicated (defaults to Monday)
// So, basically, we determine the week of year using the necessary rules,
// and we increment the day until the week number matches our "goal" week number.
// So, if the current week number is 36, and our Interval is 2, then our goal
// week number is 38.
// NOTE: fixes RRULE12 eval.
int current = _Calendar.GetWeekOfYear(old.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst),
lastLastYear = _Calendar.GetWeekOfYear(new DateTime(old.Year-1, 12, 31, 0, 0, 0, DateTimeKind.Local), System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst),
last = _Calendar.GetWeekOfYear(new DateTime(old.Year, 12, 31, 0, 0, 0, DateTimeKind.Local), System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst),
goal = current + Interval;
// If the goal week is greater than the last week of the year, wrap it!
if (goal > last)
goal = goal - last;
else if (goal <= 0)
goal = lastLastYear + goal;
int interval = Interval > 0 ? 1 : -1;
while (current != goal)
{
old = old.AddDays(interval);
current = _Calendar.GetWeekOfYear(old.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst);
}
dt = old;
break;
case FrequencyType.Monthly: dt = old.AddDays(-old.Day + 1).AddMonths(Interval); break;
case FrequencyType.Yearly: dt = old.AddDays(-old.DayOfYear + 1).AddYears(Interval); break;
default: throw new Exception("FrequencyType.NONE cannot be evaluated. Please specify a FrequencyType before evaluating the recurrence.");
}
}
示例5: CreateInitialize
public override void CreateInitialize()
{
base.CreateInitialize();
// Create a new UID for the component
UID = UniqueComponent.NewUID();
// Here, we don't simply set to DateTime.Now because DateTime.Now contains milliseconds, and
// the iCalendar standard doesn't care at all about milliseconds. Therefore, when comparing
// two calendars, one generated, and one loaded from file, they may be functionally identical,
// but be determined to be different due to millisecond differences.
DateTime now = DateTime.Now;
Created = new iCalDateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second);
DTStamp = Created.Copy();
}
示例6: EvaluateToPreviousOccurrence
private void EvaluateToPreviousOccurrence(iCalDateTime completedDate, iCalDateTime currDt)
{
iCalDateTime beginningDate = completedDate.Copy();
if (RRule != null) foreach (RecurrencePattern rrule in RRule) DetermineStartingRecurrence(rrule, ref beginningDate);
if (RDate != null) foreach (RecurrenceDates rdate in RDate) DetermineStartingRecurrence(rdate, ref beginningDate);
if (ExRule != null) foreach (RecurrencePattern exrule in ExRule) DetermineStartingRecurrence(exrule, ref beginningDate);
if (ExDate != null) foreach (RecurrenceDates exdate in ExDate) DetermineStartingRecurrence(exdate, ref beginningDate);
Evaluate(beginningDate, currDt);
}