Home Reference Source
public class | source

Duration

Represents an ISO 8601 duration. Contains both date-based values (years, months, days) and time-based values (seconds, nanoseconds). Created Duration objects are frozen with Object.freeze() in constructor and thus immutable.

Static Method Summary

Static Public Methods
public static

fromString(str: string): Duration

Creates a Duration from an ISO 8601 string NOTE: Bolt transmits durations as 4 integers: Months, Days, Seconds and Nanoseconds.

Constructor Summary

Public Constructor
public

constructor(months: NumberOrInteger, days: NumberOrInteger, seconds: NumberOrInteger, nanoseconds: NumberOrInteger)

Member Summary

Public Members
public

days: NumberOrInteger

The number of days.

public

months: NumberOrInteger

The number of months.

public

nanoseconds: NumberOrInteger

The number of nanoseconds.

public

seconds: NumberOrInteger

The number of seconds.

Static Public Methods

public static fromString(str: string): Duration source

Creates a Duration from an ISO 8601 string NOTE: Bolt transmits durations as 4 integers: Months, Days, Seconds and Nanoseconds. Parsing strings like P1.5M4.3D will throw an error. P0.5Y can be sent as it can be simplified as 6 months.

Params:

NameTypeAttributeDescription
str string

The string to convert

Return:

Duration

Public Constructors

public constructor(months: NumberOrInteger, days: NumberOrInteger, seconds: NumberOrInteger, nanoseconds: NumberOrInteger) source

Params:

NameTypeAttributeDescription
months NumberOrInteger

The number of months for the new duration.

days NumberOrInteger

The number of days for the new duration.

seconds NumberOrInteger

The number of seconds for the new duration.

nanoseconds NumberOrInteger

The number of nanoseconds for the new duration.

Public Members

public days: NumberOrInteger source

The number of days.

public months: NumberOrInteger source

The number of months.

public nanoseconds: NumberOrInteger source

The number of nanoseconds.

public seconds: NumberOrInteger source

The number of seconds.