Skip to main content

Time

Library of functions for the time type.

Functions

AddInterval

Adds an interval to a time.

Note: Years, months, weeks and days of interval will be ignored.

Syntax:
Time.AddInterval(time: time, interval: interval)
Parameters
  • time: Start time.
  • interval: interval to add.
Example:
let
t = Time.Build(0, 0),
i = Interval.Build(hours = 9, minutes = 30)
in
Time.AddInterval(t, i) // 09:30

Build

Builds a time value.

Syntax:
Time.Build(hours: int, minutes: int, seconds: optional int, milliseconds: optional int)
Parameters
  • hours: Hours component of the time to build.
  • minutes: Minutes component of the time to build.
  • seconds: Seconds component of the time to build.
  • milliseconds: Milliseconds component of the time to build.
Example:
Time.Build(9, 30) // 9:30
Time.Build(9, 30, seconds = 20) // 9:30:20
Time.Build(9, 30, seconds = 20, millis = 10) // 9:30:20.010

Hour

Returns the hours component of a time.

Syntax:
Time.Hour(time: time)
Parameters
  • time: The time from which the hours component is extracted.
Example:
Time.Hour(Time.Build(9, 30)) // 9

Millis

Returns the milliseconds component of a time.

Syntax:
Time.Millis(time: time)
Parameters
  • time: The time from which the milliseconds component is extracted.
Example:
Time.Millis(Time.Build(9, 30, millis=123)) // 123

Minute

Returns the minutes component of a time.

Syntax:
Time.Minute(time: time)
Parameters
  • time: The time from which the minutes component is extracted.
Example:
Time.Minute(Time.Build(9, 30)) // 30

Now

Returns the current time.

Syntax:
Time.Now()
Example:
Time.Now()

Parse

Parses a time from a string.

Syntax:
Time.Parse(value: string, format: string)
Parameters
  • value: The string to convert to time.
  • format: The format of the time.
Example:
Time.Parse("09:12:23.450", "H:m:s.SSS") // 09:12:23.450
Time.Parse("09:12 PM", "h:m a") // 21:12

Details

For more information about format strings see the Temporal templates documentation.

Second

Returns the seconds component of a time.

Syntax:
Time.Second(time: time)
Parameters
  • time: The time from which the seconds component is extracted.
Example:
Time.Seconds(Time.Build(9, 30, seconds=15)) // 15

Subtract

Subtracts two times.

Syntax:
Time.Subtract(time1: time, time2: time)
Parameters
  • time1: Time to be subtracted (minuend).
  • time2: Time to subtract (subtrahend).
Example:
let
t1 = Time.Build(9, 30),
t2 = Time.Build(0, 0)
in
Time.Subtract(t1, t2) // interval: hours=9, minutes=30

SubtractInterval

Subtracts an interval to a time.

Note: Years, months, weeks and days of interval will be ignored.

Syntax:
Time.SubtractInterval(time: time, interval: interval)
Parameters
  • time: Start time.
  • interval: Interval to subtract.
Example:
let
t = Time.Build(9, 30),
i = Interval.Build(hours = 9, minutes = 30)
in
Time.SubtractInterval(t, i) // 00:00