Constructor
new Duration(months, days, nanoseconds)
Creates a new instance of Duration.
Parameters:
Name | Type | Description |
---|---|---|
months |
Number | The number of months. |
days |
Number | The number of days. |
nanoseconds |
Number | Long | BigInt | The number of nanoseconds. |
- Source:
Members
(readonly) days :Number
Gets the number of days
Type:
- Number
- Source:
(readonly) months :Number
Gets the number of months
Type:
- Number
- Source:
(readonly) nanoseconds :Long
Gets the number of nanoseconds
Type:
- Long
- Source:
Methods
(package) getInternal() → {rust.DurationWrapper}
- Source:
Returns:
- Type
- rust.DurationWrapper
toBuffer() → {Buffer}
Serializes the duration and returns the representation of the value in bytes.
- Source:
Returns:
- Type
- Buffer
toString() → {string}
Returns the string representation of the value.
- Source:
Returns:
- Type
- string
(static) fromBuffer(buffer) → {Duration}
Creates a new Duration instance from the binary representation of the value.
Parameters:
Name | Type | Description |
---|---|---|
buffer |
Buffer |
- Source:
Returns:
- Type
- Duration
(package, static) fromRust(arg) → {Duration}
Get duration from rust object. Not intended to be exposed in the API
Parameters:
Name | Type | Description |
---|---|---|
arg |
rust.DurationWrapper |
- Source:
Returns:
- Type
- Duration
(static) fromString(input) → {Duration}
Creates a new Duration instance from the string representation of the value.
Parameters:
Name | Type | Description |
---|---|---|
input |
String | Accepted formats:
Duration can be made negative by adding |
- Source:
Returns:
- Type
- Duration
Examples
From formatted string
let date = fromString("4mo7d20ns"); // 1 month, 7 days, 20 nanoseconds
From ISO 8601
let date = fromString("P2DT5M"); // 2 days, 5 minutes