/// <summary> /// Returns whether or not the appointment recurs on the date in question. /// </summary> /// <param name="date"></param> /// <returns></returns> public override Boolean IsOccuringOn(Date date) { // Put a safeguard in case this code has bugs. int endlessLoopCounter = 0; const int endlessLoopTerminator = 10000; // Loop through each occurrence; starting with the first occurrence start. var occurenceStartTime = new DateTime(base.GetStartTime()); while (occurenceStartTime.CompareTo(mNotToExceedDateTime) <= 0) { // Calculate the occurrence end based on the duration. var occurenceEndTime = new DateTime(occurenceStartTime); occurenceEndTime.AddTime(0, base.GetDurationMinutes()); // Evaluate if the input date is within the occurrence window. if (date.IsBetween(occurenceStartTime.GetDate(), occurenceEndTime.GetDate())) { return(true); } endlessLoopCounter++; if (endlessLoopCounter > endlessLoopTerminator) { throw new ApplicationException("Infinite loop detected."); } occurenceStartTime.AddTime(mPeriodHours, 0); } return(false); }
/// <summary> /// Returns whether or not the appointment occurs on the date in question. /// </summary> /// <param name="date"></param> /// <returns></returns> /// <remarks> /// If the appointment occurs at any point in the day in question the method will return true. /// Even zero length appointments will return true if they occur on the date in question. /// </remarks> public override Boolean IsOccuringOn(Date date) { var endTime = GetEndTime(); var isOccuringOn = date.IsBetween(mStarts.GetDate(), endTime.GetDate()); return(isOccuringOn); }
public void AppendValue(DateTime value) { var daysUntil = value.GetDate().DaysUntil(new Date()); var minutesUntil = (long)daysUntil * MINUTESINDAY; var totalMinutes = ((long)value.GetHours() * MINUTESINHOUR) + (long)value.GetMinutes(); minutesUntil += totalMinutes; mElements.Add(new RecordElement(RecordElementType.DATETIME, minutesUntil.ToString())); }
/// <summary> /// Returns DateTime identifying properties. /// </summary> /// <returns>yyyy-MM-dd hh:mm</returns> /// <seealso cref="Helper.ToString(Date)"/> internal static String ToString(Diary.DateTime dateTime) { return(String.Format("{0} {1}:{2}", Helper.ToString(dateTime.GetDate()), dateTime.GetHours().ToString("00"), dateTime.GetMinutes().ToString("00"))); }