示例#1
0
        /// <summary>
        /// Compare method for PointInTime objects
        /// </summary>
        /// <param name="pitA">first PointInTime object</param>
        /// <param name="pitB">second PointInTime object</param>
        /// <returns>-1, if first point in time is earlier than the second one,
        ///           0, if both objects represent the same point in time
        ///           1, if first point in time is later than the second one</returns>
        public static int Compare(PointInTime pitA, PointInTime pitB)
        {
            int pA = pitA.Hour * 100 + pitA.Minute;
            int pB = pitB.Hour * 100 + pitB.Minute;

            return((pA < pB) ? -1 : (pA == pB) ? 0 : 1);
        }
示例#2
0
 /// <summary>
 /// Checking, if an enumeration of TimePeriod objects doesn't contain intersecting TimePeriods
 /// </summary>
 /// <param name="timePeriods">enumeration of Timeperiod objects to check</param>
 /// <returns>returns true, if no intersecting teime periods are found, else return false</returns>
 public static bool IsIntersectionFree(IEnumerable <TimePeriod> timePeriods)
 {
     TimePeriod[] testPeriods = timePeriods.OrderBy(tp => tp.Begin.Hour * 100 + tp.Begin.Minute).ToArray();
     for (int i = 0; i < testPeriods.Length - 1; i++)
     {
         if (PointInTime.Compare(testPeriods[i].End, testPeriods[i + 1].Begin) != -1)
         {
             return(false);
         }
     }
     return(true);
 }
 public TimePeriod(PointInTime begin, PointInTime end)
 {
     // automatically use the smaller value as period start
     if ((begin.Hour * 100 + begin.Minute) > (end.Hour * 100 + end.Minute))
     {
         Begin = end;
         End = begin;
     }
     else
     {
         Begin = begin;
         End = end;
     }
 }
示例#4
0
 public TimePeriod(PointInTime begin, PointInTime end)
 {
     // automatically use the smaller value as period start
     if ((begin.Hour * 100 + begin.Minute) > (end.Hour * 100 + end.Minute))
     {
         Begin = end;
         End   = begin;
     }
     else
     {
         Begin = begin;
         End   = end;
     }
 }
 /// <summary>
 /// Compare method for PointInTime objects
 /// </summary>
 /// <param name="pitA">first PointInTime object</param>
 /// <param name="pitB">second PointInTime object</param>
 /// <returns>-1, if first point in time is earlier than the second one,
 ///           0, if both objects represent the same point in time
 ///           1, if first point in time is later than the second one</returns>
 public static int Compare(PointInTime pitA, PointInTime pitB)
 {
     int pA = pitA.Hour * 100 + pitA.Minute;
     int pB = pitB.Hour * 100 + pitB.Minute;
     return (pA < pB) ? -1 : (pA == pB) ? 0 : 1;
 }