printTime

printTime, function

def pure printTime(dayFraction: number): text
def pure printTime(dayFraction: number, format: text): text

Formats a fraction of a day into a time-of-day text. The default format is "HH:mm:ss". This function is the reverse of parseTime.

Examples

Default format:

table T = with
  [| as DayFraction |]
  [| 0.25 |]
  [| 0.3 |]

T.Text = printTime(T.DayFraction)

show table "Formatted times" with
  T.DayFraction
  T.Text

This outputs the following table:

DayFraction Text
0.25 06:00:00
0.3 07:12:00

Custom format:

table T = with
  [| as DayFraction |]
  [| 0.5 |]
  [| 0.75 |]

T.Text = printTime(T.DayFraction, "hh-mm-ss")

show table "Formatted times" with
  T.DayFraction
  T.Text

This outputs the following table:

DayFraction Text
0.5 12-00-00
0.75 18-00-00

Remarks

The format argument uses time format specifiers (h, H, m, s, t, f, F) and literal text in single or double quotes.

Errors

printTime fails if dayFraction is not between 0 (inclusive) and 1 (exclusive), or if format is not a valid time format.

See also

User Contributed Notes
0 notes + add a note