Beispiel #1
0
 public void ExtendToCover(DateTime min, DateTime max)
 {
     try
     {
         while (min < this._min)
         {
             this._min = DateTimeSequence.AddInterval(this._min, -this._interval, this._unit);
             this._sequence.Insert(0, this._min);
         }
     }
     catch (ArgumentOutOfRangeException ex)
     {
     }
     try
     {
         while (max > this._max)
         {
             this._max = DateTimeSequence.AddInterval(this._max, this._interval, this._unit);
             this._sequence.Add(this._max);
         }
     }
     catch (ArgumentOutOfRangeException ex)
     {
     }
 }
Beispiel #2
0
        public void MoveToCover(DateTime min, DateTime max)
        {
            int num1 = (int)this._interval;

            switch (this.Unit)
            {
            case DateTimeScaleUnit.Years:
                int num2 = (min.Year - this._min.Year) / num1;
                if (num2 < 0)
                {
                    --num2;
                }
                this._min = this._min.AddYears(num2 * num1);
                break;

            case DateTimeScaleUnit.Months:
                int num3 = ((min.Year - this._min.Year) * 12 + min.Month - this._min.Month) / num1;
                if (num3 < 0)
                {
                    --num3;
                }
                this._min = this._min.AddMonths(num3 * num1);
                break;

            case DateTimeScaleUnit.Weeks:
                this._min = this._min.AddDays(Math.Floor(min.Subtract(this._min).TotalDays / 7.0 / (double)num1) * (double)num1 * 7.0);
                break;

            case DateTimeScaleUnit.Days:
                this._min = this._min.AddDays(Math.Floor(min.Subtract(this._min).TotalDays / (double)num1) * (double)num1);
                break;

            case DateTimeScaleUnit.Hours:
                this._min = this._min.AddHours(Math.Floor(min.Subtract(this._min).TotalHours / (double)num1) * (double)num1);
                break;

            case DateTimeScaleUnit.Minutes:
                this._min = this._min.AddMinutes(Math.Floor(min.Subtract(this._min).TotalMinutes / (double)num1) * (double)num1);
                break;

            case DateTimeScaleUnit.Seconds:
                this._min = this._min.AddSeconds(Math.Floor(min.Subtract(this._min).TotalSeconds / (double)num1) * (double)num1);
                break;

            case DateTimeScaleUnit.Milliseconds:
                this._min = this._min.AddMilliseconds(Math.Floor(min.Subtract(this._min).TotalMilliseconds / (double)num1) * (double)num1);
                break;

            default:
                throw new NotImplementedException();
            }
            this._sequence.Clear();
            this._sequence.Add(this._min);
            this._max = this._min;
            try
            {
                while (max > this._max)
                {
                    this._max = DateTimeSequence.AddInterval(this._max, this._interval, this._unit);
                    this._sequence.Add(this._max);
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
            }
        }