Skip to content

Commit 0d992fa

Browse files
author
alex
committed
Merge pull request '[update] calendar object and unsetWorkTime() api pages' (#112) from update-calendar-object-api-2110 into master
Reviewed-on: https://git.webix.io/Servers/gantt-docs/pulls/112 Reviewed-by: alex <[email protected]>
2 parents 1908137 + 1fe25d2 commit 0d992fa

File tree

2 files changed

+77
-25
lines changed

2 files changed

+77
-25
lines changed

data/api/gantt_calendar_other.md

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,50 +30,92 @@ The **calendar** object possesses the following methods and properties:
3030
- **_to_** - (*Date*) - the date when the time span is scheduled to be completed
3131
- **_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"])
3232
- **_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.
33-
3433

3534
~~~js
3635
calendar.setWorkTime({ hours:["9:00-18:00"] });
36+
calendar.setWorkTime({ day: 5, hours: ["9:00-18:00"] });
37+
calendar.setWorkTime({ day: 5, hours: false });
38+
calendar.setWorkTime({ date: new Date(2025, 5, 6), hours: ["9:00-18:00"] });
39+
calendar.setWorkTime({ date: new Date(2025, 5, 6), hours: false });
40+
calendar.setWorkTime({ hours: false });
41+
calendar.setWorkTime({
42+
customWeeks: {
43+
winter: {
44+
from: new Date(2025, 11, 1),
45+
to: new Date(2026, 2, 1),
46+
hours: ["8:00-13:00", "14:00-16:00"],
47+
days: [1, 1, 1, 1, 1, 0, 0]
48+
},
49+
summer: {
50+
from: new Date(2026, 5, 1),
51+
to: new Date(2026, 7, 1),
52+
hours: ["10:00-13:00", "14:00-16:00"],
53+
days: [1, 1, 0, 1, 1, 0, 0]
54+
}
55+
}
56+
});
57+
calendar.setWorkTime({
58+
customWeeks: {
59+
winter: {
60+
from: new Date(2025, 11, 1),
61+
to: new Date(2026, 2, 1),
62+
hours: ["8:00-13:00", "14:00-16:00"],
63+
days: [1, ["8:00-13:00"], 1, 1, ["14:00-16:00"], 0, 0]
64+
},
65+
summer: {
66+
from: new Date(2026, 5, 1),
67+
to: new Date(2026, 7, 1),
68+
hours: ["10:00-13:00", "14:00-16:00"],
69+
days: false
70+
}
71+
}
72+
});
3773
~~~
3874

3975
- <span class=submethod>**unsetWorkTime (config): void**</span> - unsets a working time in the Gantt Chart
4076
- **_config_** - (*object*) - the [configuration object](api/gantt_unsetworktime.md#configurationobjectproperties) of a time span:
4177
- **_day?_** - (*string | number*) - optional, a number of a week day [0 (Sunday) - 6 (Saturday)]. Note, you can set only 1 day at once
4278
- **_date?_** - (*Date*) - optional, a specific date to set as a working day or day off
4379
- **_hours?_** - (*string[] | number[] | boolean*) - optional, an array of working hours as 'from'-'to' pairs.
44-
'false' value sets a day-off, 'true' (default value) applies the default hours (["8:00-17:00"])
80+
'false' value unsets working hours, 'true' (default value) applies the default hours (["8:00-17:00"])
4581

4682

4783
~~~js
48-
calendar.unsetWorkTime({ hours:["9:00-18:00"] });
84+
calendar.unsetWorkTime({ hours: ["9:00-18:00"] });
85+
calendar.unsetWorkTime({ day: "5", hours: ["9:00-18:00"] });
86+
calendar.unsetWorkTime({ day: 5, hours: false });
87+
calendar.unsetWorkTime({ date: new Date(2025, 5, 6), hours: true });
4988
~~~
5089

5190
- <span class=submethod>**isWorkTime (config, time_unit): boolean**</span> - checks whether the specified date is working
5291
- **_config_** - (*Date | object*) - either a date to check or the [configuration object](api/gantt_isworktime.md#configurationobjectproperties) of a time span:
5392
- **_date_** - (*Date*) - a date to check
5493
- **_unit?_** - (*string*) - optional, a time unit: "minute", "hour", "day", "week", "month", "year"
55-
- **_task?_** - (*Task*) - optional, the object of the task the duration of which should be calculated
56-
- **_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<br><br>
94+
- **_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
5795

5896
~~~js
5997
var calendar = gantt.getTaskCalendar(task);
6098
if (calendar.isWorkTime({date: date})){
6199
alert("worktime of task" + task.text);
62100
}
101+
102+
calendar.isWorkTime(new Date(2025, 5, 6));
103+
calendar.isWorkTime(new Date(2025, 5, 6), "hour");
104+
calendar.isWorkTime({ date: new Date(2025, 5, 6), unit: "hour" });
63105
~~~
64106

65107
- <span class=submethod>**getClosestWorkTime (config): Date**</span> - returns the closest working time
66108
- **_config_** - (*Date | object*) - the [configuration object](api/gantt_getclosestworktime.md#configurationobjectproperties):
67109
- **_date_** - (*Date*) - a date to get the closest working time for
68110
- **_dir?_** - (*string*) - optional, specifies the direction of the closest time: "future" or "past"
69111
- **_unit?_** - (*string*) - optional, a time unit to search for the closest working time
70-
- **_task?_** - (*Task*) - optional, the object of the task to use its calendar
71112

72113
~~~js
73-
calendar.getClosestWorkTime({
74-
date:new Date(2013,0,1),
75-
dir:"future",
76-
unit:"hour"
114+
calendar.getClosestWorkTime(new Date(2025, 5, 6));
115+
calendar.getClosestWorkTime({
116+
date: new Date(2025, 5, 6),
117+
unit: "hour",
118+
dir: "past"
77119
});
78120
~~~
79121

@@ -83,26 +125,32 @@ calendar.getClosestWorkTime({
83125
- **_start_date_** - (*Date*) - the date when a task is scheduled to begin
84126
- **_duration_** - (*number*) - the duration of a task
85127
- **_unit?_** - (*string*) - optional, the time unit of the duration: "minute", "hour", "day", "week", "month", "year"
86-
- **_task?_** - (*Task*) - optional, the object of the task the duration of which should be calculated
87128
- **_duration?_** - (*number*) - optional, the duration of a task. Not needed at all when the first parameter is specified as an object
88129
- **_unit?_** - (*string*) - optional, the time unit of the duration. Not needed at all when the first parameter is specified as an object<br>
89130

90131
~~~js
91-
var end_date = calendar.calculateEndDate({start_date:date, duration:duration});
132+
calendar.calculateEndDate(new Date(2025, 5, 6), 2, "hour");
133+
calendar.calculateEndDate({
134+
start_date: new Date(2025, 5, 6),
135+
duration: 2,
136+
unit: "hour"
137+
});
92138
~~~
93139

94140
- <span class=submethod>**calculateDuration (config, end): number**</span> - calculates the duration of a task
95141
- **_config_** - (*Date | object*) - either the date when a task is scheduled to begin or the [configuration object](api/gantt_calculateduration.md#configurationobjectproperties) of a time span:
96142
- **_start_date_** - (*Date*) - the date when a task is scheduled to begin
97143
- **_end_date_** - (*Date*) - the date when a task is scheduled to be completed
98-
- **_task?_** - (*Task*) - optional, the object of the task the duration of which should be calculated
99144
- **_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<br>
100145

101146
~~~js
102-
calendar.calculateDuration(new Date(2013,02,15), new Date(2013,02,25));
147+
calendar.calculateDuration(new Date(2025, 5, 6), new Date(2025, 5, 17));
148+
calendar.calculateDuration({
149+
start_date: new Date(2025, 5, 6),
150+
end_date: new Date(2025, 5, 17)
151+
});
103152
~~~
104153

105-
106154
###Properties
107155

108156
- <span class=subproperty>**id**</span> - (*string | number*) - the id of a task's calendar

data/api/gantt_unsetworktime.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ unsetWorkTime
1515
gantt.config.work_time = true;
1616

1717
// changes the working time of working days from ["8:00-17:00"] to ["9:00-18:00"]
18-
gantt.setWorkTime({ hours:["9:00-18:00"] });
18+
gantt.setWorkTime({ hours: ["9:00-18:00"] });
1919
// unsets the working time
20-
gantt.unsetWorkTime({ hours:["9:00-18:00"] });
20+
gantt.unsetWorkTime({ hours: ["9:00-18:00"] });
2121

2222
@template: api_method
2323
@descr:
@@ -51,32 +51,36 @@ The configuration object can contain the following properties:
5151
<tr>
5252
<td colspan=2 style="text-align:left !important; ">
5353
~~~js
54-
//makes all Mondays day-offs
55-
gantt.unsetWorkTime({ day:1, hours:false });
54+
// unsets working hours for Mondays
55+
gantt.unsetWorkTime({ day: 1, hours: false });
5656
~~~
5757
</td>
5858
</tr>
5959
<tr>
6060
<td rowspan=2><b id="date">date</b></td>
61-
<td> a specific date to set as a working day or day off</td>
61+
<td> a specific date to set/unset working hours for</td>
6262
</tr>
6363
<tr>
6464
<td colspan=2 style="text-align:left !important; ">
6565
~~~js
66-
//makes a specific date a day-off
67-
gantt.unsetWorkTime({date:new Date(2013,0,1), hours:false})
66+
// unsets working hours for a specific date
67+
gantt.unsetWorkTime({
68+
date: new Date(2025, 11, 1),
69+
hours: false
70+
});
6871
~~~
6972
</td>
7073
</tr>
7174
<tr>
7275
<td rowspan=2><b id="hours">hours</b></td>
73-
<td> an array of working hours as 'from'-'to' pairs. <br><i>'false'</i> value sets a day-off, <i>'true' (default value)</i> applies the default hours (["8:00-17:00"])</td>
76+
<td> an array of working hours as 'from'-'to' pairs. <br><i>'false'</i> value unsets working hours,
77+
<i>'true' (default value)</i> applies the default hours: (["8:00-17:00"])</td>
7478
</tr>
7579
<tr>
7680
<td colspan=2 style="text-align:left !important; ">
7781
~~~js
78-
//sets the working time for Fridays from 8:00 till 12:00
79-
gantt.unsetWorkTime({day : 5, hours : ["8:00-12:00"]});
82+
// unsets the working time for Fridays from 8:00 till 12:00
83+
gantt.unsetWorkTime({ day : 5, hours : ["8:00-12:00"] });
8084
~~~
8185
</td>
8286
</tr>

0 commit comments

Comments
 (0)