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

Class hierarchy

isTimeSpan: Boolean= truereadonly
Identifies an object as an instance of TimeSpan class, or subclass thereof.
isTimeSpan: Boolean= truereadonlystatic
Identifies an object as an instance of TimeSpan class, or subclass thereof.
isModelModel
isModelLinkModelLink
isModelStmModelStm
isTimeZonedDatesMixinTimeZonedDatesMixin
isTreeNodeTreeNode

Misc

Returns the event store this event is part of, if any.

stmModelStm

Parent & children

wbsCode: String

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.

allChildrenTreeNode
childLevelTreeNode
firstChildTreeNode
isLeafTreeNode
isLoadedTreeNode
isParentTreeNode
isRootTreeNode
lastChildTreeNode
nextSiblingTreeNode
parentTreeNode
parentIdTreeNode

Scheduling

dates: Date[]readonly

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.

durationMS: Numberreadonly

Returns the duration of this Event in milliseconds.

isMilestone: Booleanreadonly

Returns true if record is a milestone.

isScheduled: Boolean

Checks if the range record has both start and end dates set and start <= end

rawDurationMS: Numberreadonly

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

copyOfModel
isValidModel

Fields

allFieldsstaticModel
autoExposeFieldsstaticModel
childrenFieldstaticModel
defaultsstaticModel
fieldMapstaticModel
fieldsstaticModel
idFieldstaticModel

Grouping

Identification

keyModel

JSON

jsonModel

Lifecycle

configBase

Linked records

hasLinksModelLink
isLinkedModelLink
recordLinksModelLink

Other

$namestaticModel
relationsstaticModel

Functions

63

Misc

Triggers a download of this time span in ICS format (for import in Outlook etc.)

timeSpan.downloadAsICS({
     LOCATION : timeSpan.location
 });
ParameterTypeDescription
icsEventConfigObject<String, String>

A config object with properties to be added in to BEGIN:VEVENT section of the exported event.

equalsModel
initClassstaticBase
isOfTypeNamestaticBase
linkModelLink
mixinstaticBase

Other

Shift the dates for the date range by the passed amount and unit

ParameterTypeDescription
amountNumber

The amount to shift

unitDurationUnit

The unit to shift by, see DateHelper for more information on valid formats.

Scheduling

Iterates over the dates

ParameterTypeDescription
funcfunction

The function to call for each date

thisObjObject

this reference for the function

Sets duration and durationUnit in one go. Only allowed way to change durationUnit, the durationUnit field is readonly after creation

ParameterTypeDescription
durationNumber

Duration value

durationUnitDurationUnit

Unit for specified duration value, see durationUnit for valid values

Sets the range end date

ParameterTypeDescription
dateDate

The new end date

keepDurationBoolean

Pass true to keep the duration of the task ("move" the event), false to change the duration ("resize" the event). Defaults to false

Sets the range start date

ParameterTypeDescription
dateDate

The new start date

keepDurationBoolean

Pass true to keep the duration of the task ("move" the event), false to change the duration ("resize" the event). Defaults to true

Sets the event start and end dates

ParameterTypeDescription
startDate

The new start date

endDate

The new end date

silentBoolean

Pass true to not trigger events

Splits this event into two pieces at the desired position.

ParameterTypeDescription
splitPointNumber | String

The duration point at which to split this event.

If less then 1, this indicates the relative position at which it will be split. 0.5 means cut it in half.

If greater than 1, this indicates the new duration in the current duration units of this event before the split.

If this is a string, it will be a duration description as described in parseDuration, for example '15 min'

Returns: TimeSpan -

The newly created split section of the timespan

Configuration

applyDefaultsstaticBase

Editing

copyModel
getDataModel
removeModel
setModel

Events

Fields

addFieldstaticModel
getModel
isTimeZoneDateFieldstaticTimeZonedDatesMixin
processFieldstaticModel
removeFieldstaticModel

Identification

asIdstaticModel
generateIdstaticModel

JSON

toJSONModel

Lifecycle

destroystaticBase

Parent & children

appendChildTreeNode
bubbleTreeNode
bubbleWhileTreeNode
containsTreeNode
insertChildTreeNode
isExpandedTreeNode
removeChildTreeNode
traverseTreeNode

Typedefs

1

Fields

9

Common

name: String

The name of the time span (or Event / Task)

Scheduling

duration: Number

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().

endDate: Date

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.

startDate: Date

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.

iconCls: String

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.

style: String

A CSS style string (applied to style.cssText) or object (applied to style)

record.style = 'color: red;font-weight: 800';