time.js
- Source
Methods
(static) createTimeRanges(start, end) → {module:time~TimeRange}
Create a TimeRange
object which mimics an HTML5 TimeRanges instance.
Name | Type | Description |
---|---|---|
start | number | | The start of a single range (a number) or an array of ranges (an array of arrays of two numbers each). |
end | number | The end of a single range. Cannot be used with the array form of the |
- Source
- Type:
- module:time~TimeRange
(static) formatTime(seconds, guide) → {string}
Delegates to either the default time formatting function or a custom function supplied via setFormatTime
.
Formats seconds as a time string (H:MM:SS or M:SS). Supplying a guide (in seconds) will force a number of leading zeros to cover the length of the guide.
Name | Type | Description |
---|---|---|
seconds | number | Number of seconds to be turned into a string |
guide | number | Number (in seconds) to model the string after |
- Source
Time formatted as H:MM:SS or M:SS
- Type:
- string
formatTime(125, 600) === "02:05"
(static) resetFormatTime()
Resets formatTime to the default implementation.
- Source
(static) setFormatTime(customImplementation)
Replaces the default formatTime implementation with a custom implementation.
Name | Type | Description |
---|---|---|
customImplementation | function | A function which will be used in place of the default formatTime implementation. Will receive the current time in seconds and the guide (in seconds) as arguments. |
- Source
Type Definitions
TimeRange
An object that contains ranges of time, which mimics TimeRanges.
- Object
Name | Type | Description |
---|---|---|
length | number | The number of time ranges represented by this object. |
start | module:time~module:time~TimeRangeIndex | Returns the time offset at which a specified time range begins. |
end | module:time~module:time~TimeRangeIndex | Returns the time offset at which a specified time range ends. |
- Source
TimeRangeIndex(indexopt) → {number}
Returns the time for the specified index at the start or end of a TimeRange object.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
index | number | <optional> | 0 | The range number to return the time for. |
- Deprecated
- The index argument must be provided. In the future, leaving it out will throw an error.
- Source
The time offset at the specified index.
- Type:
- number