CalendarException.CheckException
Contents
[
Hide
]CalendarException.CheckException method
Returns true if the specified instance of the DateTime struct is the exception day.
public bool CheckException(DateTime dt)
Parameter | Type | Description |
---|---|---|
dt | DateTime | the specified instance of the DateTime struct. |
Return Value
Returns true if DateTime value is the exception day; otherwise, false.
Examples
Shows how to add/remove calendar exceptions.
var project = new Project(DataDir + "project_test.mpp");
// create a calendar
var calendar = project.Calendars.Add("Calendar1");
// create week days exception for a holiday
var exception = new CalendarException();
exception.Name = "New Calendar Exception";
exception.EnteredByOccurrences = false;
exception.FromDate = new DateTime(2009, 12, 24, 0, 0, 0);
exception.ToDate = new DateTime(2009, 12, 31, 23, 59, 0);
exception.Type = CalendarExceptionType.Daily;
exception.Month = Month.December;
exception.DayWorking = false;
// check that date is exceptional
Console.WriteLine("Is date an exception date: " + exception.CheckException(new DateTime(2009, 12, 26, 8, 0, 0)));
calendar.Exceptions.Add(exception);
// remove an exception
var cal = project.Calendars.ToList()[0];
if (cal.Exceptions.Count > 1)
{
var excToRemove = cal.Exceptions[0];
cal.Exceptions.Remove(excToRemove);
}
// add an exception
var exception2 = new CalendarException();
exception2.FromDate = new System.DateTime(2009, 1, 1);
exception2.ToDate = new System.DateTime(2009, 1, 3);
cal.Exceptions.Add(exception2);
// print exceptions
foreach (var exc in cal.Exceptions)
{
Console.WriteLine("Name: " + exc.Name);
Console.WriteLine("From: " + exc.FromDate.ToShortDateString());
Console.WriteLine("To: " + exc.ToDate.ToShortDateString());
}
See Also
- class CalendarException
- namespace Aspose.Tasks
- assembly Aspose.Tasks