Methods
(inner) dateSpan(inBegin, inEndopt, inDurationMinsopt, inDurationSecsopt, inDurationMsopt)
Functional constructor which creates an instance of a DateSpan object.
Each DateSpan object is immutable.
A DateSpan represents a slice of time between a definite begin time
and a definite end time. This means that a DateSpan object is anchored
to a specific date and time.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
inBegin |
Date | Date object representing the starting time of the DateSpan. | ||
inEnd |
Date |
<optional> |
null | Date object representing the end time of the DateSpan. If null is passed then inDurationMins must be specified. An error is thrown if neither inEnd nor inDurationMins are specified. inEnd must be equal to or after inBegin. |
inDurationMins |
number |
<optional> |
0 | Integer representing the duration of the DateSpan in [minutes]. Must be greater than zero if inEnd is not specified. An error is thrown if both inEnd and inDurationMins are specified. |
inDurationSecs |
number |
<optional> |
0 | Integer representing the [seconds] component of the duration. Value defaults to zero if not specified. An error is thrown if both inEnd and inDurationMins are specified. |
inDurationMs |
number |
<optional> |
0 | Integer representing the [milliseconds] component of the duration. Value defaults to zero if not specified. An error is thrown if both inEnd and inDurationMins are specified. |
- Source:
Throws:
Error
Returns:
module:schedtime/datespan Instance of DateSpan object.
(inner) mergeSpans(inSpans) → {Array}
Merge multiple, intersecting and non-intersecting date-spans within an array.
Parameters:
Name | Type | Description |
---|---|---|
inSpans |
Array | Array of date-spans. All of the date-spans do not have to be intersecting but those which are will be merged together using a union operation. An Error is thrown if an array is not passed as the argument. |
- Source:
Throws:
Error
Returns:
Array containing the merged and unmerged date-spans.
- Type
- Array
(inner) sortSpans(inSpans, inIsDescendingopt) → {Array}
Sort multiple date-spans within an array by their start time.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
inSpans |
Array | Array of date-spans. An Error is thrown if an array is not passed as the argument. | ||
inIsDescending |
boolean |
<optional> |
false | true if date-spans should be sorted in descending order. The default is true which means the date-spans should be sorted in ascending order. |
- Source:
Throws:
Error
Returns:
Array containing the sorted date-spans.
- Type
- Array