TimeSpan
This class represent a simple date range. It is being used in various subclasses and plugins which operate on date ranges.
It's a subclass of Model. Please refer to documentation of those classes to become familiar with the base interface of this class.
A TimeSpan has the following fields:
- startDate - start date of the task in the ISO 8601 format
- endDate - end date of the task in the ISO 8601 format (not inclusive)
- duration - duration, time between start date and end date
- durationUnit - unit used to express the duration
- name - an optional name of the range
- cls - an optional CSS class to be associated with the range.
The data source of any field can be customized in the subclass. Please refer to Model for details. To specify another date format:
class MyTimeSpan extends TimeSpan {
static get fields() {
{ name: 'startDate', type: 'date', dateFormat: 'DD/MM/YY' }
}
}
Properties
70
Properties
70Class hierarchy
Parent & children
Returns the WBS code of this model (e.g '2.1.3'). Only relevant when part of a tree store, as in the Gantt chart.
Scheduling
Returns an array of dates in this range. If the range starts/ends not at the beginning of day, the whole day will be included.
Returns the duration of this Event in milliseconds.
Returns true if record is a milestone.
Checks if the range record has both start and end dates set and start <= end
Returns the event raw duration in milliseconds. Calculated as a simple distance between the event start and end dates in milliseconds. And thus this value (in Scheduler Pro and Gantt) doesn't take into account non-working time nor the project conversion rates.
Editing
JSON
Functions
63
Functions
63Misc
Triggers a download of this time span in ICS format (for import in Outlook etc.)
timeSpan.downloadAsICS({
LOCATION : timeSpan.location
});
| Parameter | Type | Description |
|---|---|---|
icsEventConfig | Object<String, String> | A config object with properties to be added in to |
Other
Shift the dates for the date range by the passed amount and unit
| Parameter | Type | Description |
|---|---|---|
amount | Number | The amount to shift |
unit | DurationUnit | The unit to shift by, see DateHelper for more information on valid formats. |
Scheduling
Iterates over the dates
| Parameter | Type | Description |
|---|---|---|
func | function | The function to call for each date |
thisObj | Object |
|
Sets duration and durationUnit in one go. Only allowed way to change durationUnit, the durationUnit field is readonly after creation
| Parameter | Type | Description |
|---|---|---|
duration | Number | Duration value |
durationUnit | DurationUnit | Unit for specified duration value, see durationUnit for valid values |
Sets the range end date
| Parameter | Type | Description |
|---|---|---|
date | Date | The new end date |
keepDuration | Boolean | Pass |
Sets the range start date
| Parameter | Type | Description |
|---|---|---|
date | Date | The new start date |
keepDuration | Boolean | Pass |
Sets the event start and end dates
| Parameter | Type | Description |
|---|---|---|
start | Date | The new start date |
end | Date | The new end date |
silent | Boolean | Pass |
Splits this event into two pieces at the desired position.
| Parameter | Type | Description |
|---|---|---|
splitPoint | Number | String | The duration point at which to split this event. If less then If greater than If this is a string, it will be a duration description as described in
parseDuration, for example |
The newly created split section of the timespan
Configuration
Editing
Events
Parent & children
Typedefs
1
Typedefs
1Fields
9
Fields
9Common
The name of the time span (or Event / Task)
Scheduling
The numeric part of the timespan's duration (the number of units).
The unit part of the TimeSpan duration, defaults to "d" (days). Valid values are:
- "millisecond" - Milliseconds
- "second" - Seconds
- "minute" - Minutes
- "hour" - Hours
- "day" - Days
- "week" - Weeks
- "month" - Months
- "quarter" - Quarters
- "year"- Years
This field is readonly after creation, to change durationUnit use #setDuration().
The end date of a time span (or Event / Task).
Uses DateHelper.defaultFormat to convert a supplied string to a Date. To specify another format, either change that setting or subclass TimeSpan and change the dateFormat for this field.
Note that the field always returns a Date.
Calculated field which encapsulates the duration's magnitude and unit. This field will not be persisted, setting it will update the duration and durationUnit fields.
The start date of a time span (or Event / Task).
Uses DateHelper.defaultFormat to convert a supplied string to a Date. To specify another format, either change that setting or subclass TimeSpan and change the dateFormat for this field.
Note that the field always returns a Date.
Styling
An encapsulation of the CSS classes to add to the rendered time span element.
Always returns a DomClassList, but may still be treated as a string. For granular control of adding and removing individual classes, it is recommended to use the DomClassList API.
CSS class specifying an icon to apply to the rendered time span element.
Note: In case event is a milestone, using iconCls with dependency feature might slightly decrease
performance because feature will refer to the DOM to get exact size of the element.
A CSS style string (applied to style.cssText) or object (applied to style)
record.style = 'color: red;font-weight: 800';