Module: caltime/timespan

Methods

(inner) calcBeginMs(inTimeSpan) → {number}

Get the inclusive begin time of a TimeSpan in milliseconds. This is the time elapsed since 00:00:00 (midnight) of the same day.
Parameters:
Name Type Description
inTimeSpan Object A valid TimeSpan object. An error if thrown if the object is not an instance of TimeSpan.
Source:
Throws:
Error
Returns:
Start time in [milliseconds].
Type
number

(inner) calcEndMs(inTimeSpan) → {number}

Get the exclusive end time of a TimeSpan in milliseconds. This is the time elapsed since 00:00:00 (midnight) of the same day.
Parameters:
Name Type Description
inTimeSpan Object A valid TimeSpan object. An error if thrown if the object is not an instance of TimeSpan.
Source:
Throws:
Error
Returns:
End time in [milliseconds].
Type
number

(inner) mergeSpans(inSpans) → {Array}

Merge multiple, intersecting and non-intersecting timespans within an array.
Parameters:
Name Type Description
inSpans Array Array of timespans. All of the timespans 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:
TODO verify returned array is always sorted.
Type
Error
Returns:
Array containing the merged and unmerged timespans.
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

(inner) splitTime(inMilliseconds) → {Object}

Split the time of the day, when expressed in [milliseconds] into hours, minutes, seconds and milliseconds.
Parameters:
Name Type Description
inMilliseconds number Time of the day in milliseconds i.e. time elapsed since the previous midnight.
Source:
Returns:
An object with four data members, one each for the time component in hours, minutes, seconds and milliseconds.
Type
Object

(inner) timeSpan(inHours, inMinutes, inSeconds, inMilliseconds, inDurationMins, inDurationSecsopt, inDurationMsopt) → {object}

Functional constructor which creates an instance of a TimeSpan. Do not use with the 'new' operator. Each TimeSpan object is immutable. The inclusive end time of a timespan cannot exceed 23:59:59:999 i.e. the exclusive end time cannot exceed 12 midnight (00:00:00:000 of the following day). The total duration of a timespan is equal to: inDurationMins + inDurationSecs + inDurationMs
Parameters:
Name Type Attributes Default Description
inHours number Integer. Represents the 'hour of day' component of the start time of the timespan. Valid values are 0-23. An error is thrown if the integer is not specified or is not within the valid range.
inMinutes number Integer. Represents the minutes component of the start time of the timespan. Valid values are 0-59. An error is thrown if the integer is not specified or is not within the valid range.
inSeconds number Integer. Represents the seconds component of the start time of the timespan. Valid values are 0-59. An error is thrown if the integer is not specified or is not within the valid range.
inMilliseconds number Integer. Represents the milliseconds component of the start time of the timespan. Valid values are 0-999. An error is thrown if the integer is not specified or is not within the valid range.
inDurationMins number Positive integer representing the duration of the timespan in [minutes]. An error is thrown if this argument is not specified or it is not a valid, positive integer. Valid range is 0-1440.
inDurationSecs number <optional>
0 Positive integer representing the [seconds] component of the duration. An error is thrown if this argument is not specified or it is not a valid, positive integer. Valid range is 0-59.
inDurationMs number <optional>
0 Positive integer representing the [milliseconds] component of the duration. An error is thrown if this argument is not specified or it is not a valid, positive integer. Valid range is 0-999.
Source:
Returns:
A new instance of the TimeSpan object.
Type
object