calendar
the interface of the working calendar object
object calendar;
Details
Read the Work Time Calculation article for detailed info on working calendars.
The calendar object possesses the following methods and properties:
Methods
- setWorkTime (config): boolean - sets the working time for the Gantt chart
- config - (object) - the configuration object of a time span:
- day? - (string | number) - optional, a number of a week day [0 (Sunday) - 6 (Saturday)]. Note, you can set only 1 day at once
- date? - (Date) - optional, a specific date to set as a working day or day off
- hours? - (string[] | number[] | boolean) - optional, an array of working hours as 'from'-'to' pairs.'false' value sets a day-off, 'true' (default value) applies the default hours (["8:00-17:00"])
- customWeeks? - (object) - optional, an object with different working-time rules for different periods of time. The object can contain a set of key:value pairs where key is the name of a time span and value is an object with a list of attributes.
- [timespan: string] - (object) - the time span with the working time settings. The name of that object is used as the name of the time span
- from - (Date) - the date when the time span is scheduled to begin
- to - (Date) - the date when the time span is scheduled to be completed
- hours? - (string[] | number[]) - optional, an array of working hours as 'from'-'to' pairs.'false' value sets a day-off, 'true' (default value) applies the default hours (["8:00-17:00"])
- days? - (WorkDaysTuple | boolean) - optional, an array of 7 days of the week (from 0 - Sunday, to 6 - Saturday), where 1/true stands for a working day and 0/false - a non-working day.
calendar.setWorkTime({ hours:["9:00-18:00"] });
- unsetWorkTime (config): void - unsets a working time in the Gantt Chart
- config - (object) - the configuration object of a time span:
- day? - (string | number) - optional, a number of a week day [0 (Sunday) - 6 (Saturday)]. Note, you can set only 1 day at once
- date? - (Date) - optional, a specific date to set as a working day or day off
- hours? - (string[] | number[] | boolean) - optional, an array of working hours as 'from'-'to' pairs.
'false' value sets a day-off, 'true' (default value) applies the default hours (["8:00-17:00"])
calendar.unsetWorkTime({ hours:["9:00-18:00"] });
- isWorkTime (config, time_unit): boolean - checks whether the specified date is working
- config - (Date | object) - either a date to check or the configuration object of a time span:
- date - (Date) - a date to check
- unit? - (string) - optional, a time unit: "minute", "hour", "day", "week", "month", "year"
- task? - (Task) - optional, the object of the task the duration of which should be calculated
- time_unit? - (string) - optional, a time unit: "minute", "hour", "day", "week", "month", "year". Not needed at all when the first parameter is specified as an object
var calendar = gantt.getTaskCalendar(task);
if (calendar.isWorkTime({date: date})){
alert("worktime of task" + task.text);
}
- getClosestWorkTime (config): Date - returns the closest working time
- config - (Date | object) - the configuration object:
- date - (Date) - a date to get the closest working time for
- dir? - (string) - optional, specifies the direction of the closest time: "future" or "past"
- unit? - (string) - optional, a time unit to search for the closest working time
- task? - (Task) - optional, the object of the task to use its calendar
calendar.getClosestWorkTime({
date:new Date(2013,0,1),
dir:"future",
unit:"hour"
});
- calculateEndDate (config, duration, unit): Date - calculates the end date of a task
- config - (Date | object) - either the date when a task is scheduled to begin or the configuration object of a time span:
- start_date - (Date) - the date when a task is scheduled to begin
- duration - (number) - the duration of a task
- unit? - (string) - optional, the time unit of the duration: "minute", "hour", "day", "week", "month", "year"
- task? - (Task) - optional, the object of the task the duration of which should be calculated
- duration? - (number) - optional, the duration of a task. Not needed at all when the first parameter is specified as an object
- unit? - (string) - optional, the time unit of the duration. Not needed at all when the first parameter is specified as an object
var end_date = calendar.calculateEndDate({start_date:date, duration:duration});
- calculateDuration (config, end): number - calculates the duration of a task
- config - (Date | object) - either the date when a task is scheduled to begin or the configuration object of a time span:
- start_date - (Date) - the date when a task is scheduled to begin
- end_date - (Date) - the date when a task is scheduled to be completed
- task? - (Task) - optional, the object of the task the duration of which should be calculated
- end? - (Date) - the date when a task is scheduled to be completed. Not needed at all when the first parameter is specified as an object
calendar.calculateDuration(new Date(2013,02,15), new Date(2013,02,25));
Properties
- id - (string | number) - the id of a task's calendar
See also
Back to top