@jacobhumston/tc.js / ChainConvert
Defined in: chain.ts:7
A class that chains conversions together.
new ChainConvert(
time):ChainConvert
Defined in: chain.ts:16
Creates a new chain.
Note that the provided time for this constructor is converted, use ChainConvert.add to bypass this behavior.
AvailableConversions = {}
The time to chain.
ChainConvert
add(
time):ChainConvert
Defined in: chain.ts:83
Adds time to this chain. This does not modify the total, instead it’s by unit. For example, if you add 2 minutes, only the amount of minutes will be increased.
The time to add.
ChainConvert
addTotal(
time,unit):ChainConvert
Defined in: chain.ts:159
Adds time to the total of this chain. Note that this will modify the total, not the individual units. This will convert your unites in the process.
number
The time to add.
The unit of the time to add.
"microseconds" |
"milliseconds" |
"seconds" |
"minutes" |
"hours" |
"days" |
"weeks" |
"months" |
"years" |
"decades" |
"centuries" |
ChainConvert
clone():
ChainConvert
Defined in: chain.ts:140
Clones this chain.
ChainConvert
convert():
Record<"microseconds"|"milliseconds"|"seconds"|"minutes"|"hours"|"days"|"weeks"|"months"|"years"|"decades"|"centuries",number>
Defined in: chain.ts:38
Converts the time values of this chain.
Uses convert.
Record<"microseconds" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years" | "decades" | "centuries", number>
convertTo(
unit):number
Defined in: chain.ts:64
Convert the time values from this chain to a specific unit.
Uses convertTo.
The unit to get.
"microseconds" |
"milliseconds" |
"seconds" |
"minutes" |
"hours" |
"days" |
"weeks" |
"months" |
"years" |
"decades" |
"centuries" |
number
The value of the unit.
convertTotTotal():
number
Defined in: chain.ts:73
Convert to the total amount of microseconds from this chain.
Uses convertToTotal.
number
The total amount of microseconds.
divide(
time):ChainConvert
Defined in: chain.ts:122
Divides time in this chain. This does not modify the total, instead it’s by unit. For example, if you divide minutes by 2, only the amount of minutes will be divided.
The time to divide.
ChainConvert
divideTotal(
time,unit):ChainConvert
Defined in: chain.ts:195
Divides the total of this chain. Note that this will modify the total, not the individual units. This will convert your unites in the process.
number
The time to divide.
The unit of the time to divide.
"microseconds" |
"milliseconds" |
"seconds" |
"minutes" |
"hours" |
"days" |
"weeks" |
"months" |
"years" |
"decades" |
"centuries" |
ChainConvert
floorConvert():
Record<"microseconds"|"milliseconds"|"seconds"|"minutes"|"hours"|"days"|"weeks"|"months"|"years"|"decades"|"centuries",number>
Defined in: chain.ts:54
Floors the time values of this chain to the nearest whole number.
Uses floorConvert.
Record<"microseconds" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years" | "decades" | "centuries", number>
get():
Record<"microseconds"|"milliseconds"|"seconds"|"minutes"|"hours"|"days"|"weeks"|"months"|"years"|"decades"|"centuries",number>
Defined in: chain.ts:23
Gets the time values of this chain.
Record<"microseconds" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years" | "decades" | "centuries", number>
getUnit(
unit):number
Defined in: chain.ts:30
Get a specific unit from this chain.
"microseconds" |
"milliseconds" |
"seconds" |
"minutes" |
"hours" |
"days" |
"weeks" |
"months" |
"years" |
"decades" |
"centuries" |
number
multiply(
time):ChainConvert
Defined in: chain.ts:109
Multiplies time in this chain. This does not modify the total, instead it’s by unit. For example, if you multiply minutes by 2, only the amount of minutes will be multiplied.
The time to multiply.
ChainConvert
multiplyTotal(
time,unit):ChainConvert
Defined in: chain.ts:183
Multiplies the total of this chain. Note that this will modify the total, not the individual units. This will convert your unites in the process.
number
The time to multiply.
The unit of the time to multiply.
"microseconds" |
"milliseconds" |
"seconds" |
"minutes" |
"hours" |
"days" |
"weeks" |
"months" |
"years" |
"decades" |
"centuries" |
ChainConvert
reset():
ChainConvert
Defined in: chain.ts:132
Resets the time in this chain.
ChainConvert
roundConvert(
precision?):Record<"microseconds"|"milliseconds"|"seconds"|"minutes"|"hours"|"days"|"weeks"|"months"|"years"|"decades"|"centuries",number>
Defined in: chain.ts:46
Rounds the time values of this chain to the specified precision.
Uses roundConvert.
number
Record<"microseconds" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years" | "decades" | "centuries", number>
subtract(
time):ChainConvert
Defined in: chain.ts:96
Subtracts time from this chain. This does not modify the total, instead it’s by unit. For example, if you subtract 2 minutes, only the amount of minutes will be decreased.
The time to subtract.
ChainConvert
subtractTotal(
time,unit):ChainConvert
Defined in: chain.ts:171
Subtracts time from the total of this chain. Note that this will modify the total, not the individual units. This will convert your unites in the process.
number
The time to subtract.
The unit of the time to subtract.
"microseconds" |
"milliseconds" |
"seconds" |
"minutes" |
"hours" |
"days" |
"weeks" |
"months" |
"years" |
"decades" |
"centuries" |
ChainConvert
toJSON():
string
Defined in: chain.ts:148
Converts this chain to a JSON string.
This is the same as calling JSON.stringify(chain.get()).
string