Esempio n. 1
0
 public int get_working_day_same_or_before(YearMonthDay date)
 {
     int result = -1;
     if (m_validity_start.get_date() <= date.get_date())
     {
         result = lower_bound(m_working_days, 0, m_working_days.Count(), date);
         if ((result == 0) || (date.get_date() < m_working_days[result].get_date()))
         {
             if (m_working_days[result].get_date() != m_working_days[0].get_date())
             {
                 --result;
             }
             else
             {
                 result = -1;
             }
         }
     }
     return result;
 }
Esempio n. 2
0
        public bool is_contained(YearMonthDay day_iter, int distance)
        {
            int int_day_index = m_working_days.FindIndex(x => x.get_date() == day_iter.get_date());

            if (distance >= 0)
            {
                int distnace_to_end = m_working_days.Count - int_day_index;
                if (distance >= distnace_to_end)
                {
                    return false;
                }
            }
            else
            {
                int distance_to_begin = 0 - int_day_index;
                if (distance < distance_to_begin)
                {
                    return false;
                }
            }

            return true;
        }
Esempio n. 3
0
 public YearMonthDay get_working_day_same_or_later(YearMonthDay date)
 {
     int result = 0;
     if (m_validity_start.get_date() <= date.get_date())
     {
         result = lower_bound(m_working_days, 0, m_working_days.Count(), date);
     }
     return m_working_days[result];
 }
Esempio n. 4
0
 public int get_position(YearMonthDay rhs)
 {
     return m_working_days.FindIndex(x => x.get_date() == rhs.get_date());
 }
Esempio n. 5
0
        private int lower_bound(List<YearMonthDay> objDate, int begin, int end, YearMonthDay date)
        {
            int index = -1;
            YearMonthDay iter = null;
            YearMonthDay iterMax = null;

            if (end > objDate.Count)
            {
                end = objDate.Count;
            }

            for (int i = begin; i < end; i++)
            {
                iter = objDate[i];
                if (iter.get_date() >= date.get_date())
                {
                    index = i;
                    return index;
                }
                iterMax = iter;
            }
            return index;
        }