Rest
...params: [string] | [number, number, number | bigint]// equiv. to `new DataAPIDuration('-2w')`
duration('-2w')
// equiv. to `new DataAPIDuration(2, 1, 0)`
duration(12, 1, 0)
// equiv. to `DataAPIDuration.builder().build()`
duration.builder().build()
DataAPIDuration
Helpful utility for manually creating new DataAPIDuration
instances.
Contains builder methods for incrementally adding duration components, and negating the final result.
You may call each .add*()
method any number of times, in any order, before calling build
.
The .negate(sign?)
method may be called at any time to negate the final result.
.negate(sign?)
to definitively set the signA base
duration may be provided to initialize the builder with its components and its sign.
Optional
base: DataAPIDurationThe base DataAPIDuration
to initialize the builder with, if any
const base = duration('1y');
// '-1y3d15h'
const span = duration.builder(base)
.addHours(10)
.addDays(3)
.addHours(5)
.negate()
.build();
DataAPIDurationBuilder
Overview
A shorthand function-object for DataAPIDuration. May be used anywhere when creating new
DataAPIDuration
s.See DataAPIDuration and its methods for information about input parameters, formats, functions, etc.