WorkingTime Class

Represents a working time during a weekday.
Inheritance Hierarchy
SystemObject
  Aspose.TasksWorkingTime

Namespace:  Aspose.Tasks
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 21.10
Syntax
public class WorkingTime

The WorkingTime type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleWorkingTime
Initializes a new instance of the WorkingTime class with a WorkingTime interval item as 24h
Public methodCode exampleWorkingTime(DateTime, DateTime)
Initializes a new instance of the WorkingTime class with a WorkingTime interval item with specified start and finish times.
Properties
  NameDescription
Public propertyCode exampleFromTime
Gets or sets the beginning of a working time.
Public propertyCode exampleToTime
Gets or sets the end of a working time.
Methods
  NameDescription
Public methodCode exampleEquals
Checks that the objects are equal.
(Overrides ObjectEquals(Object).)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetHashCode
Returns a hash code value for the instance of the WorkingTime class.
(Overrides ObjectGetHashCode.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Shows how to work with working time information.
public void WorkWithWorkingTime()
{
    var project = new Project();
    var calendar = CreateCalendar(project);
    project.Set(Prj.Calendar, calendar);

    Console.WriteLine("Work Week Number: " + calendar.WeekDays.Count);

    // This data is all about "Details." button you can set special working times for special WeekDay or even make it nonworking
    List<WeekDay> weekDays = calendar.WeekDays.ToList();
    foreach (var day in weekDays)
    {
        Console.WriteLine(day.DayType.ToString());

        // You can further traverse through working times and display these
        foreach (var workingTime in day.WorkingTimes)
        {
            Console.WriteLine(workingTime.FromTime);
            Console.WriteLine(workingTime.ToTime);
        }
    }
}

public static Calendar CreateCalendar(Project project)
{
    var calendar = project.Calendars.Add("MyCalendar", project.Calendars.GetByName("Standard"));
    var workingTimes = new List<WorkingTime>
                           {
                               new WorkingTime(new DateTime(1, 1, 1, 9, 0, 0), new DateTime(1, 1, 1, 12, 0, 0)),
                               new WorkingTime(new DateTime(1, 1, 1, 13, 0, 0), new DateTime(1, 1, 1, 18, 0, 0))
                           };

    calendar.WeekDays.Add(new WeekDay(DayType.Monday, workingTimes));
    calendar.WeekDays.Add(new WeekDay(DayType.Tuesday, workingTimes));
    calendar.WeekDays.Add(new WeekDay(DayType.Wednesday, workingTimes));
    calendar.WeekDays.Add(new WeekDay(DayType.Thursday, workingTimes));
    calendar.WeekDays.Add(new WeekDay(DayType.Friday, workingTimes));
    calendar.WeekDays.Add(new WeekDay(DayType.Saturday));
    calendar.WeekDays.Add(new WeekDay(DayType.Sunday));

    return calendar;
}
See Also