Пример #1
0
        public virtual TimeInterval FindAbsoluteTimeIntervalWithRespectTo(DateTime referenceDate, TimeSchedule workCalendar, TimeSchedule holidayCalendar)
        {
            DateTime d;

            if (this.LeadDayType == DayType.BusinessDay && null != workCalendar)
            {
                d = workCalendar.FindAbsoluteWorkday(holidayCalendar, referenceDate, this.LeadDays);
            }
            else
            {
                d = referenceDate.AddDays(LeadDays);
            }

            if (this.LeadDays < 0)
            {
                //Happen after the reference date
                DateTime f = new DateTime(d.Year, d.Month, d.Day, this.From.Hour, this.From.Minute, this.From.Second);
                if (this.From.TimeOfDay > this.To.TimeOfDay)
                {
                    d = d.AddDays(1);
                }
                DateTime t = new DateTime(d.Year, d.Month, d.Day, this.To.Hour, this.To.Minute, this.To.Second);
                return(new TimeInterval(f, t));
            }
            else
            {
                //Happen earlier than the reference date
                DateTime t = new DateTime(d.Year, d.Month, d.Day, this.To.Hour, this.To.Minute, this.To.Second);
                if (this.From.TimeOfDay > this.To.TimeOfDay)
                {
                    d = d.AddDays(-1);
                }
                DateTime f = new DateTime(d.Year, d.Month, d.Day, this.From.Hour, this.From.Minute, this.From.Second);
                return(new TimeInterval(f, t));
            }
        }