public void Constructors()
    {
      BasicTime bt = new BasicTime("06:15");
      Assert.IsTrue(bt.Hour == 6);
      Assert.IsTrue(bt.Minute == 15);

      bt = new BasicTime("06h15");
      Assert.IsTrue(bt.Hour == 6);
      Assert.IsTrue(bt.Minute == 15);
    }
Exemple #2
0
    /// <summary>
    /// Initializes a new instance of the <see cref="TimeRange"/> class.
    /// </summary>
    /// <param name="start">The start.</param>
    /// <param name="end">The end.</param>
    public TimeRange(string start, string end)
    {
      _start = new BasicTime(start);
      _end = new BasicTime(end);

      _overMidnight = false;
      if (_end.Hour < _start.Hour)
      {
        _overMidnight = true;
      }
    }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TimeRange"/> class.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        public TimeRange(string start, string end)
        {
            _start = new BasicTime(start);
            _end   = new BasicTime(end);

            _overMidnight = false;
            if (_end.Hour < _start.Hour)
            {
                _overMidnight = true;
            }
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TimeRange"/> class.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        public TimeRange(DateTime start, DateTime end)
        {
            _start = new BasicTime(start);
            _end   = new BasicTime(end);

            _overMidnight = false;
            if (_end.Hour < _start.Hour ||
                _end.Hour == _start.Hour && _end.Minute < _start.Minute)
            {
                _overMidnight = true;
            }
        }
Exemple #5
0
    /// <summary>
    /// Initializes a new instance of the <see cref="TimeRange"/> class.
    /// </summary>
    /// <param name="start">The start.</param>
    /// <param name="end">The end.</param>
    public TimeRange(DateTime start, DateTime end)
    {
      _start = new BasicTime(start);
      _end = new BasicTime(end);

      _overMidnight = false;
      if (_end.Hour < _start.Hour ||
          _end.Hour == _start.Hour && _end.Minute < _start.Minute)
      {
        _overMidnight = true;
      }
    }
    public void OperatorsWithDateTime()
    {
      BasicTime bt = new BasicTime("06:00");

      DateTime dt = new DateTime(2009, 3, 5, 23, 30, 0, 0);
      Assert.IsTrue(bt < dt);

      dt = new DateTime(2009, 3, 5, 6, 0, 0, 0);
      Assert.IsFalse(bt < dt);
      Assert.IsTrue(bt <= dt);
      Assert.IsTrue(bt >= dt);

      dt = new DateTime(2009, 3, 5, 3, 0, 0, 0);
      Assert.IsTrue(bt > dt);
    }
Exemple #7
0
        /// <summary>
        /// Determines whether [is in range] [the specified time].
        /// </summary>
        /// <param name="time">The time.</param>
        /// <returns>
        ///     <c>true</c> if [is in range] [the specified time]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsInRange(long time)
        {
            BasicTime checkTime = new BasicTime(time);

            if (_overMidnight)
            {
                if (_start < checkTime && checkTime.Hour < 24 ||
                    _end > checkTime && checkTime.Hour > 0)
                {
                    return(true);
                }
            }
            else
            {
                if (_start < checkTime && _end > checkTime)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #8
0
    /// <summary>
    /// Determines whether [is in range] [the specified time].
    /// </summary>
    /// <param name="time">The time.</param>
    /// <returns>
    /// 	<c>true</c> if [is in range] [the specified time]; otherwise, <c>false</c>.
    /// </returns>
    public bool IsInRange(long time)
    {
      BasicTime checkTime = new BasicTime(time);

      if (_overMidnight)
      {
        if (_start < checkTime && checkTime.Hour < 24 ||
            _end > checkTime && checkTime.Hour > 0)
        {
          return true;
        }
      }
      else
      {
        if (_start < checkTime && _end > checkTime)
        {
          return true;
        }
      }
      return false;
    }
Exemple #9
0
    //private string[,] GetSearchParams(string SearchList)
    //{
    //  int pos = 0;
    //  int num = 0;
    //  int offset;

    //  while ((offset = SearchList.IndexOf(';', pos)) != -1)
    //  {
    //    pos = offset + 1;
    //    num++;
    //  }

    //  string[,] SearchParams = new string[num, 2];

    //  int startPos = 0;
    //  int endPos = 0;
    //  for (int i = 0; i < num; i++)
    //  {
    //    if ((startPos = SearchList.IndexOf('[', startPos)) != -1)
    //    {
    //      if ((endPos = SearchList.IndexOf(']', startPos + 1)) != -1)
    //      {
    //        SearchParams[i, 0] = SearchList.Substring(startPos + 1, endPos - startPos - 1);
    //      }
    //    }

    //    if ((startPos = SearchList.IndexOf('"', endPos)) != -1)
    //    {
    //      if ((endPos = SearchList.IndexOf('"', startPos + 1)) != -1)
    //      {
    //        SearchParams[i, 1] = SearchList.Substring(startPos + 1, endPos - startPos - 1);
    //      }
    //    }

    //    startPos = SearchList.IndexOf(';', startPos);
    //  }

    //  return SearchParams;
    //}

    private BasicTime GetTime(string strTime)
    {
      BasicTime time;

      try
      {
        time = new BasicTime(strTime);
      }
      catch (ArgumentOutOfRangeException)
      {
        return null;
      }
      return time;
    }