本文整理汇总了C#中DDay.iCal.DataTypes.iCalDateTime类的典型用法代码示例。如果您正苦于以下问题:C# iCalDateTime类的具体用法?C# iCalDateTime怎么用?C# iCalDateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
iCalDateTime类属于DDay.iCal.DataTypes命名空间,在下文中一共展示了iCalDateTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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 iCalDateTime(2006, 1, 1, tzid, iCal),
new iCalDateTime(2011, 1, 1, tzid, iCal));
iCalDateTime dt = new iCalDateTime(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))
{
iCalDateTime 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
示例2: Period
public Period(iCalDateTime start, TimeSpan duration)
: this()
{
StartTime = start.Copy();
if (duration != TimeSpan.MinValue)
{
Duration = new Duration(duration);
EndTime = start + duration;
}
}
开发者ID:xxjeng,项目名称:nuxleus,代码行数:10,代码来源:Period.cs
示例3: Evaluate
public override System.Collections.Generic.List<Period> Evaluate(iCalDateTime FromDate, iCalDateTime 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:xxjeng,项目名称:nuxleus,代码行数:12,代码来源:Journal.cs
示例4: 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;
}
开发者ID:xxjeng,项目名称:nuxleus,代码行数:13,代码来源:iCalDateTimeUTCSerializer.cs
示例5: TestAlarm
public void TestAlarm(string Calendar, List<iCalDateTime> Dates, iCalDateTime Start, iCalDateTime End)
{
iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Alarm\" + Calendar);
Program.TestCal(iCal);
Event evt = iCal.Events[0];
Start.iCalendar = iCal;
Start.TZID = tzid;
End.iCalendar = iCal;
End.TZID = tzid;
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<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:MaitreDede,项目名称:dday-ical,代码行数:24,代码来源:Alarm.cs
示例6: Evaluate
public override List<Period> Evaluate(iCalDateTime FromDate, iCalDateTime ToDate)
{
List<Period> periods = base.Evaluate(FromDate, ToDate);
// Add the initial specified date/time for the time zone entry
periods.Insert(0, new Period(Start, null));
return periods;
}
开发者ID:xxjeng,项目名称:nuxleus,代码行数:7,代码来源:TimeZoneInfo.cs
示例7: RECURPARSE1
public void RECURPARSE1()
{
iCalendar iCal = new iCalendar();
Event evt = iCal.Create<Event>();
evt.Summary = "Test event";
evt.Start = new iCalDateTime(2006, 10, 1, 9, 0, 0);
evt.Duration = new TimeSpan(1, 0, 0);
evt.AddRecurrencePattern(new RecurrencePattern("Every 3rd month on the last tuesday and wednesday"));
List<Occurrence> occurrences = evt.GetOccurrences(
new iCalDateTime(2006, 10, 1),
new iCalDateTime(2007, 4, 30));
iCalDateTime[] DateTimes = new iCalDateTime[]
{
new iCalDateTime(2006, 10, 1, 9, 0, 0),
new iCalDateTime(2006, 10, 25, 9, 0, 0),
new iCalDateTime(2006, 10, 31, 9, 0, 0),
new iCalDateTime(2007, 1, 30, 9, 0, 0),
new iCalDateTime(2007, 1, 31, 9, 0, 0),
new iCalDateTime(2007, 4, 24, 9, 0, 0),
new iCalDateTime(2007, 4, 25, 9, 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,代码来源:Recurrence.cs
示例8: EvaluateExRule
protected override void EvaluateExRule(iCalDateTime FromDate, iCalDateTime ToDate)
{
}
开发者ID:xxjeng,项目名称:nuxleus,代码行数:3,代码来源:TimeZoneInfo.cs
示例9: CalculateChildOccurrences
protected List<iCalDateTime> CalculateChildOccurrences(iCalDateTime StartDate, iCalDateTime EndDate)
{
TimeCalculation TC = new TimeCalculation(StartDate, EndDate, this);
switch (Frequency)
{
case FrequencyType.Yearly:
FillYearDays(TC);
FillByDay(TC);
FillMonths(TC);
break;
case FrequencyType.Weekly:
// Weeks can span across months, so we must
// fill months (Note: fixes RRULE10 eval)
FillMonths(TC);
break;
case FrequencyType.Monthly:
FillDays(TC);
FillByDay(TC);
break;
case FrequencyType.Daily:
FillHours(TC);
break;
case FrequencyType.Hourly:
FillMinutes(TC);
break;
case FrequencyType.Minutely:
FillSeconds(TC);
break;
default:
throw new NotSupportedException("CalculateChildOccurrences() is not supported for a frequency of " + Frequency.ToString());
}
// Apply the BYSETPOS to the list of child occurrences
// We do this before the dates are filtered by Start and End date
// so that the BYSETPOS calculates correctly.
// NOTE: fixes RRULE33 eval
if (BySetPos.Count != 0)
{
List<iCalDateTime> newDateTimes = new List<iCalDateTime>();
foreach (int pos in BySetPos)
{
if (Math.Abs(pos) <= TC.DateTimes.Count)
{
if (pos > 0)
newDateTimes.Add(TC.DateTimes[pos - 1]);
else if (pos < 0)
newDateTimes.Add(TC.DateTimes[TC.DateTimes.Count + pos]);
}
}
TC.DateTimes = newDateTimes;
}
// Filter dates by Start and End date
for (int i = TC.DateTimes.Count - 1; i >= 0; i--)
{
if ((iCalDateTime)TC.DateTimes[i] < StartDate ||
(iCalDateTime)TC.DateTimes[i] > EndDate)
TC.DateTimes.RemoveAt(i);
}
return TC.DateTimes;
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:63,代码来源:RecurrencePattern.cs
示例10: GetTimeZoneInfo
/// <summary>
/// Retrieves the iCalTimeZoneInfo object that contains information
/// about the TimeZone, with the name of the current timezone,
/// offset from UTC, etc.
/// </summary>
/// <param name="dt">The iCalDateTime object for which to retrieve the iCalTimeZoneInfo.</param>
/// <returns>A TimeZoneInfo object for the specified iCalDateTime</returns>
public iCalTimeZoneInfo GetTimeZoneInfo(iCalDateTime dt)
{
iCalTimeZoneInfo tzi = null;
TimeSpan mostRecent = TimeSpan.MaxValue;
foreach (iCalTimeZoneInfo 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);
// Time zones must include an effective start date/time.
if (curr.Start == null)
continue;
// Make a copy of the current start value
iCalDateTime currStart = curr.Start.Copy();
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);
// Offset the current start value to match our offset time...
currStart = currStart.AddHours(curr.TZOffsetTo.Hours * mult);
currStart = currStart.AddMinutes(curr.TZOffsetTo.Minutes * mult);
currStart = currStart.AddSeconds(curr.TZOffsetTo.Seconds * mult);
}
// Determine the UTC occurrences of the Time Zone changes
if (curr.EvalStart == null ||
curr.EvalEnd == null ||
dtUTC < curr.EvalStart.Value ||
dtUTC > curr.EvalEnd.Value)
curr.Evaluate(Start, End);
// If the date is past the last allowed date, then don't consider it!
// NOTE: if this time zone ends as another begins, then there can
// be up to a 1 year period of "unhandled" time unless we add a year
// to the "Until" date. For example, one time period "ends" in Oct. 2006
// (the last occurrence), and the next begins in Apr. 2007. If we didn't
// add 1 year to the "Until" time, the 6 month period between Oct. 2006
// and Apr. 2007 would be unhandled.
// FIXME: this thinking may be flawed. We should try to find some other way...
//
//if (curr.Until != null &&
// dtUTC > curr.Until.AddYears(1))
// continue;
foreach (Period p in curr.Periods)
{
TimeSpan currentSpan = dtUTC - p.StartTime;
if (currentSpan.Ticks >= 0 &&
currentSpan.Ticks < mostRecent.Ticks)
{
mostRecent = currentSpan;
tzi = curr;
}
}
}
return tzi;
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:73,代码来源:iCalTimeZone.cs
示例11: GetOccurrences
protected List<iCalDateTime> GetOccurrences(iCalDateTime StartDate, iCalDateTime FromDate, iCalDateTime ToDate, int Count)
{
List<iCalDateTime> DateTimes = new List<iCalDateTime>();
// If the Recur is restricted by COUNT, we need to evaluate just
// after any static occurrences so it's correctly restricted to a
// certain number. NOTE: fixes bug #13 and bug #16
if (Count > 0)
{
FromDate = StartDate;
foreach (iCalDateTime dt in StaticOccurrences)
{
if (FromDate < dt)
FromDate = dt;
}
}
// Handle "UNTIL" values that are date-only. If we didn't change values here, "UNTIL" would
// exclude the day it specifies, instead of the inclusive behaviour it should exhibit.
if (Until != null && !Until.HasTime)
Until.Value = new DateTime(Until.Year, Until.Month, Until.Day, 23, 59, 59, Until.Value.Kind);
// Ignore recurrences that occur outside our time frame we're looking at
if ((Until != null && FromDate > Until) ||
ToDate < StartDate)
return DateTimes;
// Narrow down our time range further to avoid over-processing
if (Until != null && Until < ToDate)
ToDate = Until;
if (StartDate > FromDate)
FromDate = StartDate;
// If the interval is greater than 1, then we need to ensure that the StartDate occurs in one of the
// "active" days/weeks/months/years/etc. to ensure that we properly "step" through the interval.
// NOTE: Fixes bug #1741093 - WEEKLY frequency eval behaves strangely
{
long difference = DateUtils.DateDiff(Frequency, StartDate, FromDate, Wkst);
while (difference % Interval > 0)
{
FromDate = DateUtils.AddFrequency(Frequency, FromDate, -1);
difference--;
}
}
// If the start date has no time, then our "From" date should not either
// NOTE: Fixes bug #1876582 - All-day holidays are sometimes giving incorrect times
if (!StartDate.HasTime)
{
FromDate = new iCalDateTime(FromDate.Year, FromDate.Month, FromDate.Day, StartDate.Hour, StartDate.Minute, StartDate.Second);
FromDate.IsUniversalTime = StartDate.IsUniversalTime;
FromDate.HasTime = false;
}
while (
FromDate <= ToDate &&
(
Count == int.MinValue ||
DateTimes.Count <= Count)
)
{
// Retrieve occurrences that occur on our interval period
if (BySetPos.Count == 0 && IsValidDate(FromDate) && !DateTimes.Contains(FromDate.Value))
DateTimes.Add(FromDate.Copy());
// Retrieve "extra" occurrences that happen within our interval period
if (Frequency > FrequencyType.Secondly)
{
foreach (iCalDateTime dt in GetExtraOccurrences(FromDate, ToDate))
{
// Don't add duplicates
if (!DateTimes.Contains(dt))
DateTimes.Add(dt.Copy());
}
}
IncrementDate(ref FromDate);
}
return DateTimes;
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:81,代码来源:RecurrencePattern.cs
示例12: 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.");
}
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:41,代码来源:RecurrencePattern.cs
示例13: TimeCalculation
public TimeCalculation(iCalDateTime StartDate, iCalDateTime EndDate, RecurrencePattern Recur)
{
this.StartDate = StartDate;
this.EndDate = EndDate;
this.Recur = Recur;
Year = StartDate.Value.Year;
Month = StartDate.Value.Month;
Day = StartDate.Value.Day;
Hour = StartDate.Value.Hour;
Minute = StartDate.Value.Minute;
Second = StartDate.Value.Second;
YearDays = new List<int>(Recur.ByYearDay);
ByDays = new List<DaySpecifier>(Recur.ByDay);
Months = new List<int>(Recur.ByMonth);
Days = new List<int>(Recur.ByMonthDay);
Hours = new List<int>(Recur.ByHour);
Minutes = new List<int>(Recur.ByMinute);
Seconds = new List<int>(Recur.BySecond);
DateTimes = new List<iCalDateTime>();
// Only check what months and days are possible for
// the week's period of time we're evaluating
// NOTE: fixes RRULE10 evaluation
if (Recur.Frequency == FrequencyType.Weekly)
{
if (Months.Count == 0)
{
Months.Add(StartDate.Value.Month);
if (StartDate.Value.Month != EndDate.Value.Month)
Months.Add(EndDate.Value.Month);
}
if (Days.Count == 0)
{
DateTime dt = StartDate.Value;
while (dt < EndDate.Value)
{
Days.Add(dt.Day);
dt = dt.AddDays(1);
}
Days.Add(EndDate.Value.Day);
}
}
else
{
if (Months.Count == 0) Months.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });
if (Days.Count == 0) Days.AddRange(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 });
}
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:50,代码来源:RecurrencePattern.cs
示例14: CheckValidDate
/// <summary>
/// [Deprecated]: Use IsValidDate() instead.
/// </summary>
public bool CheckValidDate(iCalDateTime dt) { return IsValidDate(dt); }
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:4,代码来源:RecurrencePattern.cs
示例15: RRULE6
public void RRULE6()
{
iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE6.ics");
Program.TestCal(iCal);
Event evt = iCal.Events[0];
List<Occurrence> occurrences = evt.GetOccurrences(
new iCalDateTime(1998, 1, 1, tzid, iCal),
new iCalDateTime(2000, 12, 31, tzid, iCal));
iCalDateTime dt = new iCalDateTime(1998, 1, 1, 9, 0, 0, tzid, iCal);
int i = 0;
while (dt.Year < 2001)
{
if (dt >= evt.Start &&
dt.Month == 1 &&
dt <= new iCalDateTime(2000, 1, 31, 9, 0, 0, tzid, iCal))
{
Assert.AreEqual(dt, occurrences[i].Period.StartTime, "Event should occur at " + dt);
i++;
}
dt = dt.AddDays(1);
}
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:25,代码来源:Recurrence.cs
示例16: 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.AddRecurrencePattern(new RecurrencePattern("Every month on the first sunday, at 5:00PM, and at 7:00PM"));
List<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,代码来源:Recurrence.cs
示例17: 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.AddRecurrencePattern(new RecurrencePattern("Every 10 minutes until 1/1/2006 9:50"));
List<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,代码来源:Recurrence.cs
示例18: IsValidDate
/// <summary>
/// Returns true if <paramref name="dt"/> is a date/time that aligns to (occurs within)
/// the recurrence pattern of this Recur, false otherwise.
/// </summary>
public bool IsValidDate(iCalDateTime dt)
{
if (BySecond.Count != 0 && !BySecond.Contains(dt.Value.Second)) return false;
if (ByMinute.Count != 0 && !ByMinute.Contains(dt.Value.Minute)) return false;
if (ByHour.Count != 0 && !ByHour.Contains(dt.Value.Hour)) return false;
if (ByDay.Count != 0)
{
bool found = false;
foreach (DaySpecifier bd in ByDay)
{
if (bd.CheckValidDate(this, dt))
{
found = true;
break;
}
}
if (!found)
return false;
}
if (ByWeekNo.Count != 0)
{
bool found = false;
int lastWeekOfYear = _Calendar.GetWeekOfYear(new DateTime(dt.Value.Year, 12, 31), System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst);
int currWeekNo = _Calendar.GetWeekOfYear(dt.Value, System.Globalization.CalendarWeekRule.FirstFourDayWeek, Wkst);
foreach (int WeekNo in ByWeekNo)
{
if ((WeekNo > 0 && WeekNo == currWeekNo) ||
(WeekNo < 0 && lastWeekOfYear + WeekNo + 1 == currWeekNo))
found = true;
}
if (!found)
return false;
}
if (ByMonth.Count != 0 && !ByMonth.Contains(dt.Value.Month)) return false;
if (ByMonthDay.Count != 0)
{
// Handle negative days of month (count backwards from the end)
// NOTE: fixes RRULE18 eval
bool found = false;
int DaysInMonth = _Calendar.GetDaysInMonth(dt.Value.Year, dt.Value.Month);
foreach (int Day in ByMonthDay)
{
if ((Day > 0) && (Day == dt.Value.Day))
found = true;
else if ((Day < 0) && (DaysInMonth + Day + 1 == dt.Value.Day))
found = true;
}
if (!found)
return false;
}
if (ByYearDay.Count != 0)
{
// Handle negative days of year (count backwards from the end)
// NOTE: fixes RRULE25 eval
bool found = false;
int DaysInYear = _Calendar.GetDaysInYear(dt.Value.Year);
DateTime baseDate = new DateTime(dt.Value.Year, 1, 1);
foreach (int Day in ByYearDay)
{
if (Day > 0 && dt.Value.Date == baseDate.AddDays(Day - 1))
found = true;
else if (Day < 0 && dt.Value.Date == baseDate.AddYears(1).AddDays(Day))
found = true;
}
if (!found)
return false;
}
return true;
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:75,代码来源:RecurrencePattern.cs
示例19: RRULE13
public void RRULE13()
{
iCalendar iCal = iCalendar.LoadFromFile(@"Calendars\Recurrence\RRULE13.ics");
Program.TestCal(iCal);
Event evt = iCal.Events[0];
List<Occurrence> occurrences = evt.GetOccurrences(
new iCalDateTime(1996, 1, 1, tzid, iCal),
new iCalDateTime(1999, 1, 1, tzid, iCal));
iCalDateTime[] DateTimes = new iCalDateTime[]
{
new iCalDateTime(1997, 9, 2, 9, 0, 0, tzid, iCal),
new iCalDateTime(1997, 9, 4, 9, 0, 0, tzid, iCal),
new iCalDateTime(1997, 9, 16, 9, 0, 0, tzid, iCal),
new iCalDateTime(1997, 9, 18, 9, 0, 0, tzid, iCal),
new iCalDateTime(1997, 9, 30, 9, 0, 0, tzid, iCal),
new iCalDateTime(1997, 10, 2, 9, 0, 0, tzid, iCal),
new iCalDateTime(1997, 10, 14, 9, 0, 0, tzid, iCal),
new iCalDateTime(1997, 10, 16, 9, 0, 0, tzid, iCal)
};
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,代码行数:30,代码来源:Recurrence.cs
示例20: EnsureByXXXValues
protected void EnsureByXXXValues(iCalDateTime StartDate)
{
// If the frequency is weekly, and
// no day of week is specified, use
// the original date's day of week.
// NOTE: fixes RRULE7 and RRULE8 handling
if (Frequency == FrequencyType.Weekly &&
ByDay.Count == 0)
this.ByDay.Add(new DaySpecifier(StartDate.Value.DayOfWeek));
if (Frequency > FrequencyType.Secondly &&
this.BySecond.Count == 0 &&
StartDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
this.BySecond.Add(StartDate.Value.Second);
if (Frequency > FrequencyType.Minutely &&
this.ByMinute.Count == 0 &&
StartDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
this.ByMinute.Add(StartDate.Value.Minute);
if (Frequency > FrequencyType.Hourly &&
this.ByHour.Count == 0 &&
StartDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
this.ByHour.Add(StartDate.Value.Hour);
// If neither BYDAY, BYMONTHDAY, or BYYEARDAY is specified,
// default to the current day of month
// NOTE: fixes RRULE23 handling, added BYYEARDAY exclusion
// to fix RRULE25 handling
if (Frequency > FrequencyType.Weekly &&
this.ByMonthDay.Count == 0 &&
this.ByYearDay.Count == 0 &&
this.ByDay.Count == 0)
this.ByMonthDay.Add(StartDate.Value.Day);
// If neither BYMONTH nor BYYEARDAY is specified, default to
// the current month
// NOTE: fixes RRULE25 handling
if (Frequency > FrequencyType.Monthly &&
this.ByYearDay.Count == 0 &&
this.ByDay.Count == 0 &&
this.ByMonth.Count == 0)
this.ByMonth.Add(StartDate.Value.Month);
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:39,代码来源:RecurrencePattern.cs
注:本文中的DDay.iCal.DataTypes.iCalDateTime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论