Schedules
A Schedule is a plan for carrying out a process or procedure, providing lists of intended events and times. The Scenario (project) object has a default Schedule, as do individual Resources.
Resource schedules inherit the effects of calendars in the project or of calendars in any groups the resources are inside, but they don't inherit the calendars themselves. For example, if you add a vacation day in the project calendar, every resource will not work that day, but that doesn't change each resource's individual calendars.
Think of it this way:
- A Calendar as a list of changes from what the resource would normally be doing.
- A Schedule is the resulting work times, taking into account all of the calendars for the resource and up the hierarchy of groups and the project.
Instance Properties
The properties of an instance of the Schedule class:
calendars (Array of ResourceCalendar r/o) • All calendars in this schedule. OmniPlan manages two built-in calendars for each schedule: an off-time calendar and an overtime calendar. Additional calendars may be added by synchronizing with Calendar.app or ical URLs, etc.
Instance Functions
Here are the functions that can be called on an instance of the Schedule class.
endDate(start:Date, duration:Duration) → (Date) • Compute the end date for a given start date and duration in this schedule.
startDate(end:Date, duration:Duration) → (Date) • Compute the start date for a given end date and duration in this schedule.
durationBetween(start:Date, end:Date) → (Duration) • Compute the work-second duration between a given start date and end date in this schedule.
The following script example uses the startDate and endDate properties of the Scenario class (not to be confused with the startDate() and endDate() functions of the Schedule class), along with the durationBetween(…) instance function of the Schedule class, in order to display a dialog showing the current length of the project measured in days.
Show Project Length in Days
var sDate = actual.startDate
var eDate = actual.endDate
var projectDuration = actual.schedule.durationBetween(sDate, eDate)
var projectDays = projectDuration.workSeconds/86400
projectDays = projectDays.toFixed(2)
var alertTitle = "Project Length in Days"
var alertMessage = "The current project length is " + String(projectDays) + " days."
new Alert(alertTitle, alertMessage).show()