Object - thyme : Duration

Represents a mutable chunk of time without particular start or end.

Methods

Clone the current status of a Duration, since it's mutable. Example:
 Duration d = someDuration.clone();
Get the current value of a single unit type. Example:
 int|error i = someDuration.get("hour");
Get total value of duration as an int. Example:
 int|error i = someDuration.totalAsInt("minute");
Get total value of duration as a float. Example:
 float|error f = someDuration.totalAsFloat("minute");

clone

()

returns Duration
Clone the current status of a Duration, since it's mutable. Example:
 Duration d = someDuration.clone();

get

(string unit)

returns int | error
Get the current value of a single unit type. Example:
 int|error i = someDuration.get("hour");

Parameters

  • unit string
  • A valid unit from DURATION_UNIT_OPTIONS

  • Return Type

    (int | error)
  • An int, or an error if unknown unit

totalAsInt

(string unit)

returns int | error
Get total value of duration as an int. Example:
 int|error i = someDuration.totalAsInt("minute");

Parameters

  • unit string
  • A valid unit from DURATION_UNIT_OPTIONS

  • Return Type

    (int | error)
  • An int, or an error if unknown unit or conversions inside fail

totalAsFloat

(string unit)

returns float | error
Get total value of duration as a float. Example:
 float|error f = someDuration.totalAsFloat("minute");

Parameters

  • unit string
  • A valid unit from DURATION_UNIT_OPTIONS

  • Return Type

    (float | error)
  • A float, or an error if unknown unit or conversions inside fail