Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Duration

A class that stores information about a time duration.

author

"Travis Redpath"

Hierarchy

  • Duration

Index

Properties

Protected _duration

_duration: string = ""

Protected _token

_token: string = ""

Protected _tokenIndex

_tokenIndex: number = 0

days

days: number = -1

The number of days in the duration. Leave as 0 or less for no days.

hours

hours: number = -1

The number of hours in the duration. Leave as 0 or less for no hours.

isNegative

isNegative: boolean = false

Is the duration negative in direction.

minutes

minutes: number = -1

The number of minutes in the duration. Leave as 0 or less for no miutes.

months

months: number = -1

The number of months in the duration. Leave as 0 or less for no months.

seconds

seconds: number = -1

The number of seconds in the duration. Leave as 0 or less for no seconds. Fractions of a second can be specified.

years

years: number = -1

The number of years in the duration. Leave as 0 or less for no years.

Methods

Protected _nextToken

  • _nextToken(): string
  • Returns string

Protected _parse

  • _parse(): void
  • Returns void

Protected _parseDate

  • _parseDate(): void
  • Returns void

Protected _parseDateModifier

  • _parseDateModifier(num: string): void
  • Parameters

    • num: string

    Returns void

Protected _parseTime

  • _parseTime(): void
  • Returns void

Protected _parseTimeModifier

  • _parseTimeModifier(num: string): void
  • Parameters

    • num: string

    Returns void

fromString

  • fromString(val: string): void
  • Convert an xml duration string into a Duration object.

    Parameters

    • val: string

      The xml duration string. An exception will be thrown if the string is not in the correct format.

    Returns void

isLessThan

  • Is the current duration less than another.

    internal

    Parameters

    • other: Duration

      The other duration to compare against.

    Returns boolean

isValid

  • isValid(): boolean
  • Is the duration valid (at least one value has been specified).

    Returns boolean

    boolean

toDays

  • toDays(): number
  • Convert the years/months/days portion of the duration into a number of days. Will be an approximation because the duration doesn't reference a specific year.

    internal

    Returns number

    The number of days represented by the duration. Will be negative if {@link Duration#isNegative} is true.

toSeconds

  • toSeconds(): number
  • Convert the days/hours/minutes/seconds portion of the duration into a number of seconds.

    internal

    Returns number

    The number of seconds represented by the duration. Will be negative if {@link Duration#isNegative} is true.

toString

  • toString(): string
  • Convert the Duration into a properly formatted xml duration string.

    Returns string

Static createDate

  • createDate(years: number, months: number, days: number, negative: boolean): Duration
  • Create a new time duration with only date parameters.

    Parameters

    • years: number
    • months: number
    • days: number
    • negative: boolean

      Is the duration negative in time.

    Returns Duration

Static createDateTime

  • createDateTime(years: number, months: number, days: number, hours: number, minutes: number, seconds: number, negative: boolean): Duration
  • Create a new time duration.

    Parameters

    • years: number
    • months: number
    • days: number
    • hours: number
    • minutes: number
    • seconds: number
    • negative: boolean

      Is the duration negative in time.

    Returns Duration

Static createTime

  • createTime(hours: number, minutes: number, seconds: number, negative: boolean): Duration
  • Create a new time duration with only time parameters.

    Parameters

    • hours: number
    • minutes: number
    • seconds: number
    • negative: boolean

      Is the duration negative in time.

    Returns Duration