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); }
public CalendarSpan(CalendarSpan source) { if (source != null) { _calendarValue = source.CalendarValue; _calendarType = source.CalendarType; } else { _calendarValue = null; _calendarType = CalendarTypes.Days; } }