Ejemplo n.º 1
0
        public static DateTime AddCalendarSpan(this DateTime dateTime, CalendarSpan calendarSpan)
        {
            if (calendarSpan == null)
            {
                return(new DateTime(dateTime.Ticks));
            }

            DateTime result;

            switch (calendarSpan.CalendarType)
            {
            case CalendarTypes.Days:
                result = dateTime.AddDays(System.Convert.ToDouble(calendarSpan.CalendarValue));
                break;

            case CalendarTypes.Months:
                result = dateTime.AddMonths(System.Convert.ToInt32(calendarSpan.CalendarValue));
                break;

            case CalendarTypes.Years:
                result = dateTime.AddYears(System.Convert.ToInt32(calendarSpan.CalendarValue));
                break;

            default:
                result = new DateTime(dateTime.Ticks);
                break;
            }

            return(result);
        }
Ejemplo n.º 2
0
 public CalendarSpan(CalendarSpan source)
 {
     if (source != null)
     {
         _calendarValue = source.CalendarValue;
         _calendarType  = source.CalendarType;
     }
     else
     {
         _calendarValue = null;
         _calendarType  = CalendarTypes.Days;
     }
 }