Esempio n. 1
0
        /// <summary>
        /// Create interval, parsing from string form:
        /// <p>
        /// Form can be one of:
        /// <ul>
        ///     <li>[<time>, <time>]</li>
        ///     <li><time>,<time></li>
        /// </ul>
        /// </summary>
        /// <param name='interval'>
        /// Interval.
        /// </param>
        /// <exception cref='Exception'>
        /// Represents errors that occur during application execution.
        /// </exception>
        public ZTimeRange(string interval)
        {
            int isplit = interval.IndexOf(',');

            if (isplit == -1)
            {
                throw new Exception("time interval not in proper format: " + interval);
            }

            string sstart = interval.Substring(0, isplit).Trim();
            string send   = interval.Substring(isplit + 1).Trim();

            if (sstart[0] == '[')
            {
                sstart = sstart.Substring(1);
            }
            if (send[send.Length - 1] == ']')
            {
                send = send.Substring(0, send.Length - 1);
            }

            _start = new ZTime(sstart);
            _end   = new ZTime(send);
            Debug.Assert(_end.MilliSecond >= _start.MilliSecond);
        }
Esempio n. 2
0
 /// <summary>
 /// etermine if time after time-interval
 /// </summary>
 /// <param name='time'>
 /// time to consider
 /// </param>
 public bool After(ZTime time)
 {
     return(_end < time);
 }
Esempio n. 3
0
 /// <summary>
 /// Create interval spanning start to end times
 /// </summary>
 /// <param name='start'>
 /// Start time.
 /// </param>
 /// <param name='end'>
 /// End time.
 /// </param>
 public ZTimeRange(ZTime start, ZTime end)
 {
     _start = start;
     _end   = end;
     Debug.Assert(end.MilliSecond >= start.MilliSecond);
 }
Esempio n. 4
0
 /// <summary>
 /// Determine if time within time-interval
 /// </summary>
 /// <param name='time'>
 /// time to consider
 /// </param>
 public bool Within(ZTime time)
 {
     return(_start <= time && _end >= time);
 }
Esempio n. 5
0
 /// <summary>
 /// Determine if time before time-interval
 /// </summary>
 /// <param name='time'>
 /// time to consider
 /// </param>
 public bool Before(ZTime time)
 {
     return(_start > time);
 }
Esempio n. 6
0
 /// <summary>
 /// Determine if time for given clock time within time-interval
 /// </summary>
 /// <param name='clock'>
 /// clock stamp from which time is extracted (in local timezone)
 /// </param>
 public bool Within(long clock)
 {
     return(Within(ZTime.TimeOf(clock)));
 }
Esempio n. 7
0
        // Operations


        /// <summary>
        /// Determine if time for given date within time-interval
        /// </summary>
        /// <param name='date'>
        /// date from which time is extracted (in local timezone)
        /// </param>
        public bool Within(ZDateTime date)
        {
            return(Within(ZTime.TimeOf(date)));
        }
Esempio n. 8
0
        public override bool Equals(object obj)
        {
            ZTime o = (ZTime)obj;

            return(_time == o._time);
        }
Esempio n. 9
0
 /// <summary>
 /// Provide the difference Ta and Tb in milliseconds (Ta - Tb).
 /// </summary>
 /// <param name='Ta'>
 /// Ta.
 /// </param>
 /// <param name='Tb'>
 /// Tb.
 /// </param>
 public static long Difference(ZTime Ta, ZTime Tb)
 {
     return(Ta._time - Tb._time);
 }
Esempio n. 10
0
 /// <summary>
 /// Provide offset in milliseconds from other time (if this time is > other will be +, otherwise -)
 /// </summary>
 /// <returns>
 /// Millisecond difference
 /// </returns>
 /// <param name='other'>
 /// Other time
 /// </param>
 public long OffsetFrom(ZTime other)
 {
     return(Difference(this, other));
 }