Пример #1
0
        // Returns true if the specified date falls inside the range of this date instance.
        private bool Encompasses( CPGDate date )
        {
            if (date == null)
            {
                return false;
            }

            switch( m_etType )
            {
                case EType.PeriodFrom:
                case EType.RangeAfter:
                    return date.IsAfter( m_uDay, m_uMonth, m_year.m_nYear );

                case EType.PeriodTo:
                case EType.RangeBefore:
                    return date.IsBefore( m_uDay, m_uMonth, m_year.m_nYear );

                case EType.PeriodFromTo:
                case EType.RangeBetween:
                    return date.IsBefore( m_uDayTo, m_uMonthTo, m_yearTo.m_nYear )
                        && date.IsAfter( m_uDay, m_uMonth, m_year.m_nYear );

                case EType.Single:
                case EType.ApproximatedAbout:
                case EType.ApproximatedCalculated:
                case EType.ApproximatedEstimate:
                case EType.Interpreted:
                case EType.Phrase:
                default:
                    return date.Encompasses( m_uDay, m_uMonth, m_year.m_nYear );
            }
        }
Пример #2
0
        // Returns the number of days difference between the two given dates, or 0 if the date ranges overlap.
        public static int Difference( CPGDate date1, CPGDate date2 )
        {
            AssertLower( ref date1 );
              AssertHigher( ref date2 );
              // If date2 encompasses date1, difference = 0
              if (date2.Encompasses(date1))
              {
              return 0;
              }
              // If date1 encompasses date2, difference = 0
              if (date1.Encompasses(date2))
              {
              return 0;
              }

              return CountDays( date1.m_uDay, date1.m_uMonth, date1.m_year.m_nYear, date2.m_uDay, date2.m_uMonth, date2.m_year.m_nYear );
        }