Skip to main content

Interval

Library of functions for the interval type.

Functions

Build

Creates an interval.

Syntax:
Interval.Build(years: optional int, months: optional int, weeks: optional int, days: optional int, hours: optional int, minutes: optional int, seconds: optional int, millis: optional int)
Parameters
  • years: Number of years in the interval.
  • months: Number of months in the interval.
  • weeks: Number of weeks in the interval.
  • days: Number of days in the interval.
  • hours: Number of hours in the interval.
  • minutes: Number of minutes in the interval.
  • seconds: Number of seconds in the interval.
  • millis: Number of milli-seconds in the interval.
Example:
Interval.Build(hours = 1, minutes = 30)
Interval.Build(years = 3, months = 6, days = 5)

Days

"Gets the days part of an interval.

Syntax:
Interval.Days(value: interval)
Parameters
  • value: The interval to get the days from.
Example:
Interval.Days(Interval.Build(years = 2, days = 20)) // 20 

FromMillis

Converts a number of milliseconds to the corresponding interval

Syntax:
Interval.FromMillis(mills: long)
Parameters
  • mills: The number of milliseconds to be converted to interval.
Example:
Interval.FromMillis(60000) // interval 60 seconds

Hours

"Gets the hours part of an interval.

Syntax:
Interval.Hours(value: interval)
Parameters
  • value: The interval to get the hours from.
Example:
Interval.Hours(Interval.Build(years = 2, hours = 12)) // 12 

Millis

"Gets the milliseconds part of an interval.

Syntax:
Interval.Millis(value: interval)
Parameters
  • value: The interval to get the milli-seconds from.
Example:
Interval.Millis(Interval.Build(years = 2, millis = 230)) // 230 

Minutes

"Gets the minutes part of an interval.

Syntax:
Interval.Minutes(value: interval)
Parameters
  • value: The interval to get the minutes from.
Example:
Interval.Minutes(Interval.Build(years = 2, minutes = 15)) // 15 

Months

"Gets the months part of an interval.

Syntax:
Interval.Months(value: interval)
Parameters
  • value: The interval to get the months from.
Example:
Interval.Months(Interval.Build(years = 2, months = 10)) // 10 

Parse

"Parses an interval from a string. The interval format for the string has to be the ISO-8601 for durations, see https://en.wikipedia.org/wiki/ISO_8601#Durations

Syntax:
Interval.Parse(str: string)
Parameters
  • str: The string to be parsed as interval.
Example:
Interval.Parse("P1Y2M") // interval 1 year, 2 months
Interval.Parse("PT1M2S") // interval 1 minute, 2 seconds
Interval.Parse("P1Y2M3DT4H5M6.007S") // interval 1 year, 2 months, 3 days, 4 hours, 5 minutes, 6 seconds, 7 milliseconds

Seconds

"Gets the seconds part of an interval.

Syntax:
Interval.Seconds(value: interval)
Parameters
  • value: The interval to get the seconds from.
Example:
Interval.Seconds(Interval.Build(years = 2, seconds = 45)) // 45 

ToMillis

Converts a interval to the corresponding number of milliseconds

Syntax:
Interval.ToMillis(intrvl: interval)
Parameters
  • intrvl: The interval to be converted to milliseconds.
Example:
Interval.ToMillis(Interval.Build(minutes=1)) // 60000
Interval.ToMillis(Interval.Build(days=1)) //86400000 (24*60*60*1000)

Weeks

"Gets the weeks part of an interval.

Syntax:
Interval.Weeks(value: interval)
Parameters
  • value: The interval to get the weeks from.
Example:
Interval.Weeks(Interval.Build(years = 2, weeks = 4)) // 4 

Years

"Gets the years part of an interval.

Syntax:
Interval.Years(value: interval)
Parameters
  • value: The interval to get the years from.
Example:
Interval.Years(Interval.Build(years = 2, days = 20)) // 2