Ejemplo n.º 1
0
        /// <summary>
        /// Returns the holidays between two dates
        /// </summary>
        public static List <Date> holidayList(Calendar calendar, Date from, Date to, bool includeWeekEnds = false)
        {
            Utils.QL_REQUIRE(to > from, () => "'from' date (" + from + ") must be earlier than 'to' date (" + to + ")");
            List <Date> result = new List <Date>();

            for (Date d = from; d <= to; ++d)
            {
                if (calendar.isHoliday(d) &&
                    (includeWeekEnds || !calendar.isWeekend(d.DayOfWeek)))
                {
                    result.Add(d);
                }
            }
            return(result);
        }
        public static List <Date> holidayList(Calendar calendar, Date from, Date to, bool includeWeekEnds)
        {
            if (to <= from)
            {
                throw new Exception("'from' date (" + from + ") must be earlier than 'to' date (" + to + ")");
            }

            List <Date> result = new List <Date>();

            for (Date d = from; d <= to; ++d)
            {
                if (calendar.isHoliday(d) &&
                    (includeWeekEnds || !calendar.isWeekend(d.DayOfWeek)))
                {
                    result.Add(d);
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public static object TestCalendars(string CalendarName, DateTime StartDate, DateTime EndDate)
        {
            Type tt = CommonTypes.Utils.FindType(CalendarName, null);

            ql.Calendar cal = (ql.Calendar)Activator.CreateInstance(tt);

            int nDays = (int)(EndDate - StartDate).TotalDays;

            object[,] ret = new object[nDays, 2];

            for (int i = 0; i < nDays; ++i)
            {
                DateTime date = StartDate.AddDays(i);
                ret[i, 0] = date.ToOADate();
                ret[i, 1] = cal.isHoliday(new ql.Date(date));
            }

            return(ret);
        }
        public static List<Date> holidayList(Calendar calendar, Date from, Date to, bool includeWeekEnds) {
            if (to <= from)
            {
                throw new Exception("'from' date (" + from + ") must be earlier than 'to' date (" + to + ")");
            }

            List<Date> result = new List<Date>();

            for (Date d = from; d <= to; ++d)
            {
                if (calendar.isHoliday(d)
                    && (includeWeekEnds || !calendar.isWeekend(d.DayOfWeek)))
                    result.Add(d);
            }
            return result;
        }