public bool Equals(SimpleTime time) { // Check for null. if (time == null) { return(false); } // Check for ReferenceEquals if this is a reference type. if (ReferenceEquals(this, time)) { return(true); } // Possibly check for equivalent hash codes. if (this.GetHashCode() != time.GetHashCode()) { return(false); } // Check base.Equals if base overrides Equals(). System.Diagnostics.Debug.Assert(base.GetType() != typeof(object)); if (!base.Equals(time)) { return(false); } // Compare identifying fields for equality. return(this.hour.Equals(time.hour) && this.minute.Equals(time.minute) && this.second.Equals(time.second)); }
public bool ContainsTime(SimpleTime st) { bool result = false; foreach (TimeRange tr in timeRanges) { if (tr.ContainsTime(st)) { result = true; break; } } return(result); }
public bool ContainsTime(SimpleTime timeToCheck) { bool result = false; foreach (TimeRange range in ranges) { if (range.ContainsTime(timeToCheck)) { result = true; break; } } return(result); }
/* * // The WeekDay (Monday, Tuesday, etc) is contained WITHIN the DailyTimeRange object. * public void AddDailyTimeRange(DailyTimeRange dtr) * { * // Don't add a null TimeRange. * if (dtr == null) * return; * * // If there is not already a DailyTimeRange for the specified WeekDay, then * // set our DailyTimeRange for the WeekDay to the specified DailyTimeRange. * if (dailyTimeRanges[dtr.WeekDay] == null) * { * // We are going to use a CLONE of the DailyTimeRange so we can modify it within * // our WeeklyTimeRange (such as adding TimeRanges to it) without affecting the * // original DailyTimeRange object. * dailyTimeRanges[dtr.WeekDay] = dtr.Clone() as DailyTimeRange; * } * else * { * // ADD TO our existing DailyTimeRange for this WeekDay. * DailyTimeRange existingDTR = dailyTimeRanges[dtr.WeekDay]; * * foreach (TimeRange tr in dtr.TimeRanges) * { * existingDTR.AddTimeRange(tr); * } * } * }*/ public bool ContainsTime(SimpleTime st) { bool result = false; foreach (DailyTimeRange dtr in dailyTimeRanges.Values) { if (dtr.ContainsTime(st)) { result = true; break; } } return(result); }
public int CompareTo(object obj) { if (!(obj is SimpleTime)) { throw new ArgumentException("object is not a SimpleTime"); } SimpleTime st2 = obj as SimpleTime; // Start off assuming a result of equality (zero). int result = 0; // Work our way through testing hour, minute, second. if (this.hour > st2.hour) { result = 1; } else if (this.hour < st2.hour) { result = -1; } else if (this.minute > st2.minute) { result = 1; } else if (this.minute < st2.minute) { result = -1; } else if (this.second > st2.second) { result = 1; } else if (this.second < st2.second) { result = -1; } return(result); }
public TimeRange() { // Default StartTime to very beginning of day and EndTime to very end of day. beginTime = new SimpleTime(0, 0, 0); endTime = new SimpleTime(23, 59, 59); }
public bool ContainsTime(SimpleTime timeToCheck) { return(beginTime <= timeToCheck && endTime >= timeToCheck); }