Skip to content

Period

Type

The Period type represents calendar time.

A Period is initialized through the built-in function days(), weeks(), months(), or years().

Period is normalized. This means adding 8 months and 6 months leads to 1 year and 2 months (days are left unaffected).

See plus() and minus() for how to add/subtract Period to/from DateTime.

Methods

plus

<function> Adds two Periods.

Receiver

Period

Arguments

delta - Period

Returns

Period

Usage
days(5).plus(weeks(4)) == days(33)

minus

<function> Subtracts two Periods.

Receiver

Period

Arguments

delta - Period

Returns

Period

Usage
weeks(5).minus(days(4)) == days(31)

multiplyBy

<function> Multiplies Period by a constant.

Receiver

Period

Arguments

multiplier - Number

Returns

Period

Usage

multiplyBy(scale: Number), where scale.isInteger() == true, multiplies a Period by a scale.

days(5).multiplyBy(2) == days(10)

Inherited methods

toText

<function> Obtain the Text representation of this.

Receiver

T

Type Arguments

T

Returns

Text - the Text representation of this

Usage

Converts a Period to Text. Weeks are converted to days (7) for Period. Values of 0 are left out of the toText() result.

years(10).plus(days(2)).toText() == "10years 2days"