Duration

Class which represents a duration object. A duration consists of a magnitude and a unit.

{
   unit      : String,
   magnitude : Number
}

Valid values are:

  • "millisecond" - Milliseconds
  • "second" - Seconds
  • "minute" - Minutes
  • "hour" - Hours
  • "day" - Days
  • "week" - Weeks
  • "month" - Months
  • "quarter" - Quarters
  • "year"- Years

Properties

3
magnitude: Number

Get/Set numeric magnitude value.

milliseconds: Numberreadonly

The milliseconds property is a read only property which returns the number of milliseconds in this Duration

Get/set duration unit to use with the current magnitude value. Valid values are:

  • "millisecond" - Milliseconds
  • "second" - Seconds
  • "minute" - Minutes
  • "hour" - Hours
  • "day" - Days
  • "week" - Weeks
  • "month" - Months
  • "quarter" - Quarters
  • "year"- Years

Functions

7

Lifecycle

Duration constructor.

ParameterTypeDescription
magnitudeNumber | String

Duration magnitude value or a duration + magnitude string ('2h', '4d')

unitDurationUnit

Duration unit value

Other

Returns a new Duration which is the sum of this Duration and the passed Duration. The returned Duration unit is the same as this Duration's unit.

ParameterTypeDescription
otherDurationDuration
Returns: Duration

Returns a new Duration which is the difference between this Duration and the passed Duration. The returned Duration unit is the same as this Duration's unit.

ParameterTypeDescription
otherDurationDuration
Returns: Duration
fromstatic

Converts the passed parameter converted to a Duration object if possible, or null if null or undefined passed.

ParameterTypeDescription
sourceNumber | String | Object | Duration

The data to be converted into a Duration.

Returns: Duration -

The passed parameter converted to a Duration object if possible, or null if null or undefined passed.

Returns truthy value if this Duration equals the passed value.

ParameterTypeDescription
valueDuration
Returns: Boolean

Returns a negated copy of this Duration.

Returns: Duration -

a negated copy of this Duration.

Returns a readable localized representation of this Duration (e.g. 5 days).

ParameterTypeDescription
useAbbreviationBoolean

Pass true to return an abbreviated version (e.g. 5d)

nbrDecimalsBoolean

The maximum number of decimals for comparison and displaying in the editor

Returns: String

Typedefs

1

Object describing a duration.

ParameterTypeDescription
magnitudeNumber

The magnitude of the duration

unitDurationUnit

The unit of the duration