ICAL. Duration

This class represents the "duration" value type, with various calculation and manipulation methods.

Constructor

new Duration(data)

Creates a new ICAL.Duration instance.

Parameters:
NameTypeDescription
dataObject

An object with members of the duration

Properties
NameTypeDescription
weeksNumber

Duration in weeks

daysNumber

Duration in days

hoursNumber

Duration in hours

minutesNumber

Duration in minutes

secondsNumber

Duration in seconds

isNegativeBoolean

If true, the duration is negative

Members

days :Number

The days in this duration

Type:
  • Number
Default Value
  • 0

hours :Number

The days in this duration

Type:
  • Number
Default Value
  • 0

(constant) icalclass :String

The class identifier.

Type:
  • String
Default Value
  • "icalduration"

(constant) icaltype :String

The type name, to be used in the jCal object.

Type:
  • String
Default Value
  • "duration"

isNegative :Boolean

The seconds in this duration

Type:
  • Boolean
Default Value
  • false

minutes :Number

The minutes in this duration

Type:
  • Number
Default Value
  • 0

seconds :Number

The seconds in this duration

Type:
  • Number
Default Value
  • 0

weeks :Number

The weeks in this duration

Type:
  • Number
Default Value
  • 0

Methods

clone() → {ICAL.Duration}

Returns a clone of the duration object.

Returns:

The cloned object

Type: 
ICAL.Duration

compare(aOther) → {Number}

Compares the duration instance with another one.

Parameters:
NameTypeDescription
aOtherICAL.Duration

The instance to compare with

Returns:

-1, 0 or 1 for less/equal/greater

Type: 
Number

fromData(aData)

Sets up the current instance using members from the passed data object.

Parameters:
NameTypeDescription
aDataObject

An object with members of the duration

Properties
NameTypeDescription
weeksNumber

Duration in weeks

daysNumber

Duration in days

hoursNumber

Duration in hours

minutesNumber

Duration in minutes

secondsNumber

Duration in seconds

isNegativeBoolean

If true, the duration is negative

fromSeconds(aSeconds) → {ICAL.Duration}

Reads the passed seconds value into this duration object. Afterwards, members like days and weeks will be set up accordingly.

Parameters:
NameTypeDescription
aSecondsNumber

The duration value in seconds

Returns:

Returns this instance

Type: 
ICAL.Duration

normalize()

Normalizes the duration instance. For example, a duration with a value of 61 seconds will be normalized to 1 minute and 1 second.

reset()

Resets the duration instance to the default values, i.e. PT0S

toICALString() → {String}

The iCalendar string representation of this duration.

Returns:
Type: 
String

toSeconds() → {Number}

The duration value expressed as a number of seconds.

Returns:

The duration value in seconds

Type: 
Number

toString() → {String}

The string representation of this duration.

Returns:
Type: 
String

(static) fromData(aData) → {ICAL.Duration}

Creates a new ICAL.Duration instance from the given data object.

Parameters:
NameTypeDescription
aDataObject

An object with members of the duration

Properties
NameTypeDescription
weeksNumber

Duration in weeks

daysNumber

Duration in days

hoursNumber

Duration in hours

minutesNumber

Duration in minutes

secondsNumber

Duration in seconds

isNegativeBoolean

If true, the duration is negative

Returns:

The createad duration instance

Type: 
ICAL.Duration

(static) fromSeconds(aSeconds) → {ICAL.Duration}

Returns a new ICAL.Duration instance from the passed seconds value.

Parameters:
NameTypeDescription
aSecondsNumber

The seconds to create the instance from

Returns:

The newly created duration instance

Type: 
ICAL.Duration

(static) fromString(aStr) → {ICAL.Duration}

Creates a new ICAL.Duration instance from the passed string.

Parameters:
NameTypeDescription
aStrString

The string to parse

Returns:

The created duration instance

Type: 
ICAL.Duration

(static) isValueString(value) → {Boolean}

Checks if the given string is an iCalendar duration value.

Parameters:
NameTypeDescription
valueString

The raw ical value

Returns:

True, if the given value is of the duration ical type

Type: 
Boolean