new Engine(expression [, pattern])
Kairos time engine.
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
expression |
String | Number | Kairos.Engine | Literal time expression, milliseconds or a Kairos.Engine instance | |
pattern |
String |
<optional> |
Overrides Kairos pattern |
Examples
new Kairos.Engine('10:30', 'hh:mm');
new Kairos.Engine(1000);
new kairos.Engine(previousInstance);
Members
-
<protected> milliseconds :Number
-
Type:
- Number
- Default Value:
-
- 0
Methods
-
addHours(hours)
-
Adds hours to the current instance.
Parameters:
Name Type Description hoursNumber Hours to add Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').addHours(1); -
addMilliseconds(milliseconds)
-
Adds milliseconds in the current instance.
Parameters:
Name Type Description millisecondsNumber Milliseconds to add Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').addMilliseconds(500); -
addMinutes(minutes)
-
Adds minutes to the current instance.
Parameters:
Name Type Description minutesNumber Minutes to add Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').addMinutes(30); -
addSeconds(seconds)
-
Adds seconds in the current instance.
Parameters:
Name Type Description secondsNumber Seconds to add Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').addSeconds(30); -
compareTo(another [, pattern])
-
Compares with another instance.
Parameters:
Name Type Argument Description anotherString | Number | Kairos.Engine Expression to compare with patternString <optional>
Overrides Kairos pattern Returns:
Smaller -1 | Equals 0 | Bigger 1- Type
- Number
Example
new Kairos.Engine('01:00').compareTo('00:30'); -
divide(divisor)
-
Divies by the given dividend.
Parameters:
Name Type Description divisorNumber Divisor value Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').divide(2); -
getHours()
-
Gets hours fraction in the current instance.
Returns:
Hours fraction from the instance- Type
- Number
Example
new Kairos.Engine('01:00').getHours(); -
getMilliseconds()
-
Gets milliseconds fraction in the current instance.
Returns:
Milliseconds fraction from the instance- Type
- Number
Example
new Kairos.Engine('01:00').getMilliseconds(); -
getMinutes()
-
Gets minutes fraction in the current instance.
Returns:
Minutes fraction from the instance- Type
- Number
Example
new Kairos.Engine('01:00').getMinutes(); -
getSeconds()
-
Gets seconds fraction in the current instance.
Returns:
Seconds fraction from the instance- Type
- Number
Example
new Kairos.Engine('01:00').getSeconds(); -
minus(subtrahend [, pattern])
-
Subtracts the given subtrahend.
Parameters:
Name Type Argument Description subtrahendNumber | String | Kairos.Engine patternString <optional>
Overrides Kairos pattern Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').minus('00:30'); -
multiply(multiplicand)
-
Multiply by the given multiplicand.
Parameters:
Name Type Description multiplicandNumber Multiplicand value Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').multiply(2); -
plus(addend [, pattern])
-
Sums the given addend.
Parameters:
Name Type Argument Description addendNumber | String | Kairos.Engine patternString <optional>
Overrides Kairos pattern Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').minus('00:30'); -
removeHours(hours)
-
Removes hours from the current instance.
Parameters:
Name Type Description hoursNumber Hours to remove Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').removeHours(1); -
removeMilliseconds(milliseconds)
-
Removes milliseconds from the current instance.
Parameters:
Name Type Description millisecondsNumber Milliseconds to remove Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').removeMilliseconds(50); -
removeMinutes(minutes)
-
Removes minutes from the current instance.
Parameters:
Name Type Description minutesNumber Minutes to remove Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').removeMinutes(30); -
removeSeconds(seconds)
-
Removes seconds from the current instance.
Parameters:
Name Type Description secondsNumber Seconds to remove Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').removeSeconds(30); -
setHours(hours)
-
Sets hours fraction in the current instance.
Parameters:
Name Type Description hoursNumber Hours to set Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('02:00').setHours(1); -
setMilliseconds(milliseconds)
-
Sets milliseconds fraction in the current instance.
Parameters:
Name Type Description millisecondsNumber Milliseconds to set Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').setMilliseconds(200); -
setMinutes(minutes)
-
Sets minutes fraction in the current instance.
Parameters:
Name Type Description minutesNumber Minutes to set Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').setMinutes(30); -
setSeconds(seconds)
-
Sets seconds fraction in the current instance.
Parameters:
Name Type Description secondsNumber Seconds to set Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').setSeconds(30); -
toAbsolute()
-
Makes the current instance's value absolute.
Returns:
Self- Type
- Kairos.Engine
Example
new Kairos.Engine('01:00').toAbsolute(); -
toHours()
-
Returns total hours within the current instance.
Returns:
Hours within the current instance- Type
- Number
Example
new Kairos.Engine('01:00').toHours(); -
toMilliseconds()
-
Returns total milliseconds within the current instance.
Returns:
Milliseconds within the current instance- Type
- Number
Example
new Kairos.Engine('01:00').toMilliseconds(); -
toMinutes()
-
Returns total minutes within the current instance.
Returns:
Minutes within the current instance- Type
- Number
Example
new Kairos.Engine('01:00').toMinutes(); -
toSeconds()
-
Returns total seconds within the current instance.
Returns:
Seconds within the current instance- Type
- Number
Example
new Kairos.Engine('01:00').toSeconds(); -
toString(pattern, allowOverflow)
-
Returns a string representation of the object.
Parameters:
Name Type Description patternString Pattern to format the time expression allowOverflowBoolean If true, when hour field is bigger than the pattern definition, it will be printed anyway Returns:
String representing the instance time- Type
- String
Example
new Kairos.Engine('22:10').toString('hh:mm');