Format
Format( "format", arg, ... )
Format( "format", Arr(arg, ...) )
Format( "format", arg, ... )
Format( "format", Arr(arg, ...) )
Format( "format", arg, ... )
Format( "format", Arr(arg, ...) )
Format( 'format', arg, ... )
Format( 'format', [ arg, ... ] )
format( "format", arg, ... )
format( "format", [ arg, ... ] )
Not available in this language yet.
Format( "format", arg, ... )
Format( "format", Arr(arg, ...) )
Not available in this language yet.
Description
The Format
function applies the format
argument to compose a string
by converting the remaining arguments to strings. Format
is very
similar to the printf()
function that is available in many languages.
The format
argument is a string that includes format
specifiers that define how arguments should be converted to strings.
format
should contain as many format specifiers as there are remaining
arguments. format
can include fewer format specifiers than remaining
arguments, but an errors occurs when more format specifiers are
included than remaining arguments.
If an argument cannot be formatted according to format
, an error is
returned.
Returns
A string value representing the formatted arguments, or an error if any format conversion fails.
Format
The format
parameter is a string that contains format specifiers.
Each format specifier defines how a function argument is to be converted
into a string. Format specifiers use the following syntax:
%[index][flags][width][.precision]conversion[suffix]
-
The optional
index
specification is a positive decimal integer (>= 1) that indicates the relative position of the argument to format from the argument list.format
, as the first function argument, has a zero offset in the argument list. The next argument has an offset of 1, followed by 2, and so on. -
The optional
flags
specification is a set of characters that modify the output format. The set of valid flags depends on theconversion
. See Flags for details. -
The optional
width
specification is a positive decimal integer indicating the minimum number of characters to be included in the output for this conversion. -
The optional
precision
specification is a non-negative decimal integer that is usually used to restrict the number of characters produced for this conversion. The specific behavior depends on theconversion
. -
The required
conversion
specification is a character that indicates how the associated argument is to be formatted when it is converted to a string. The set of valid conversions for a given argument depends on the argument’s data type. See Conversions for details. -
The optional
suffix
specification is a character that indicates which time or date field to use for timestamp conversions. See Suffixes for dates, Suffixes for times, or Suffixes for dates and times for details.
Flags
Flag | Description |
---|---|
|
The result is left-justified. |
|
The result always includes a sign, positive or negative. |
|
The result includes a leading space for positive values. |
|
The result is zero padded. |
|
The result encloses negative numbers in parentheses. |
Conversions
Conversion | Description |
---|---|
|
The result is formatted as a decimal integer. |
|
The result is formatted as a hexadecimal integer. |
|
The result is formatted as a hexadecimal integer. All letters are converted to uppercase. |
|
The result is formatted as an octal integer. |
|
The result is formatted as a decimal number. |
|
The result is formatted as a number using scientific notation. |
|
The result is formatted as a number using scientific notation. All letters are converted to uppercase. |
|
The result is formatted as a number using scientific notation, or a decimal number, depending on the precision. |
|
The result is formatted as a number using scientific notation, or a decimal number, depending on the precision. All letters are converted to uppercase. |
|
The result is formatted as string. If the argument is |
|
The result is formatted as string. If the argument is |
|
|
|
The result is formatted as boolean. |
|
The result is formatted as boolean. All letters are converted to uppercase. |
|
The literal character |
|
The system-specific line break. |
|
The result is formatted as the FaunaDB wire protocol. (This is a debug conversion which applies to all non-scalar values) |
Suffixes for dates
The following are suffixes for the %t
conversion that are used to
format specific date fields:
Suffix | Description |
---|---|
|
The full month name, e.g. |
|
The abbreviated month name, e.g. |
|
The same as the |
|
The full name of the day of the week, e.g. |
|
The abbreviated name of the day of the week, e.g. |
|
The year divided by 100 (the century), formatted as 2 digits with leading zeroes as necessary, e.g. 00-99. |
|
The year, formatted as 4 digits with leading zeroes as necessary, in the range 0000-9999. |
|
The last two digits of the year, formatted with leading zeroes as necessary, in the range 00-99. |
|
The day of the year, formatted as 3 digits with leading zeroes as necessary, in the range 001-366. |
|
The month, formatted as 2 digits with a leading zero as necessary, in the range 01-13 (13 is required for lunar calendars). |
|
The day of the month, formatted as 2 digits with a leading zero as necessary, in the range 01-31. |
|
The day of month, formatted as 2 characters with a leading space as necessary, in the range 1-31. |
|
The date, formatted as |
|
The date formatted as |
Suffixes for times
The following are suffixes for the %t
conversion that are used to
format specific time fields:
Suffix | Description |
---|---|
|
The hour, formatted as 2 digits with leading zeroes as necessary, in the range 00-23. |
|
The hour, formatted as 2 digits with a leading zero as necessary, in the range 01-12. |
|
The hour, formatted as 1 or 2 digits, in the range 0-23. |
|
The hour, formatted as 1 or 2 digits, in the range 1-12. |
|
The minute, formatted as 2 digits with leading zeroes as necessary, in the range 00-59. |
|
The second, formatted as 2 digits with leading zeroes as necessary, in the range 00-60. |
|
The millisecond within the second, formatted as 3 digits with leading zeroes as necessary, in the range 000-999. |
|
The nanosecond within the second, formatted as 9 digits with leading zeroes as necessary, in the range 000000000-999999999. |
|
The morning or afternoon marker, |
|
The seconds since epoch (1970-01-01T00:00:00+00:00). |
|
The milliseconds since epoch (1970-01-01T00:00:00.000+00:00). |
Suffixes for dates and times
The following are suffixes for the %t
conversion that are used to
format common date+time compositions:
Suffix | Description |
---|---|
|
The time as |
|
The time as |
|
The time as |
|
The date as |
|
The date as |
|
The date and time as |
Examples
Value result = await client.Query(
Let(
"ts", Time("2019-08-16T18:51:33.987654321+00:00")
).In(
Concat(
Arr(
Format("%nDecimals:"),
Repeat("-=", 30),
Format(" normal: '%d'", 123),
Format(" with sign: '%+d'", 123),
Format(" with width: '%7d'", 123),
Format(" with width, align left: '%-7d'", 123),
Format(" as hexadecimal: '%x'", 123),
Format("as hexadecimal, uppercase: '%X'", 123),
Format(" as octal: '%o'", 123),
Format("%nFloats:"),
Repeat("=-", 30),
Format(" normal: '%f'", 123.456789),
Format(" 2 decimals: '%.2f'", 123.456789),
Format(" scientific notation: '%e'", 123.456789),
Format("scientific notation, 2 decimals: '%.2e'", 123.456789),
Format(" scientific notation, uppercase: '%E'", 123.456789),
Format(" %%g: '%g'", 123.456789),
Format(" %%g, 2 decimals: '%.2g'", 123.456789),
Format(" %%G: '%g'", 123.456789),
Format(" %%G, 2 decimals: '%.2g'", 123.456789),
Format("%nStrings:"),
Repeat("-=", 30),
Format(" normal: '%s'", "Fauna"),
Format("uppercase: '%S'", "Fauna"),
Format(" null: '%s'", null),
Format(" %%%%: '%%'"),
Format("linefeed: %n"),
Format("%nBooleans:"),
Repeat("=-", 30),
Format(" true: '%b'", true),
Format(" true, uppercase: '%B'", 1),
Format(" false: '%b'", false),
Format("false, uppercase: '%B'", 0),
Format("%nTimes and Dates:"),
Repeat("-=", 30),
Format(" ISO-8601: %t", Var("ts")),
Format(" ISO-8601, uppercase: %T", Var("ts")),
Format(""),
Format(" Full month name: %tB", Var("ts")),
Format(" Full month name, uppercase: %TB", Var("ts")),
Format(" Short month name: %tb", Var("ts")),
Format(" Short month name, uppercase: %Tb", Var("ts")),
Format(" %%h: %th", Var("ts")),
Format(" %%h, uppercase: %Tb", Var("ts")),
Format(" Full weekday: %tA", Var("ts")),
Format(" Full weekday, uppercase: %TA", Var("ts")),
Format(" Short weekday: %ta", Var("ts")),
Format(" Short weekday, uppercase: %Ta", Var("ts")),
Format(" Century: %tC", Var("ts")),
Format(" Year: %tY", Var("ts")),
Format(" Short year: %ty", Var("ts")),
Format(" Day of the year: %tj", Var("ts")),
Format(" Month: %tm", Var("ts")),
Format(" Day of the month: %td", Var("ts")),
Format(""),
Format(" Hour, leading 0's (24): %tH", Var("ts")),
Format(" Hour, leading 0's (12): %tI", Var("ts")),
Format(" Hour (24): %tk", Var("ts")),
Format(" Hour (12): %tl", Var("ts")),
Format(" Minute: %tM", Var("ts")),
Format(" Second: %tS", Var("ts")),
Format(" Millisecond: %tL", Var("ts")),
Format(" Nanosecond: %tN", Var("ts")),
Format(" Morning/afternoon: %tp", Var("ts")),
Format("Morning/afternoon, uppercase: %Tp", Var("ts")),
Format(" Seconds since epoch: %ts", Var("ts")),
Format(" Milliseconds since epoch: %tQ", Var("ts")),
Format(""),
Format(" %%R: %tR", Var("ts")),
Format(" %%T: %tT", Var("ts")),
Format(" %%r: %tr", Var("ts")),
Format(" %%D: %tD", Var("ts")),
Format(" %%F: %tF", Var("ts")),
Format(" %%c: %tc", Var("ts")),
Format("")
),
"\n"
)
)
);
Console.WriteLine(
JsonConvert.SerializeObject(result, Formatting.Indented)
.Replace("\\n", "\n")
);
result, err := client.Query(
f.Let().Bind("ts", f.Time("2019-08-16T18:51:33.987654321+00:00")).In(
f.Concat(
f.Arr{
f.Format("%nDecimals:"),
f.Repeat("-=", 30),
f.Format(" normal: '%d'", 123),
f.Format(" with sign: '%+d'", 123),
f.Format(" with width: '%7d'", 123),
f.Format(" with width, align left: '%-7d'", 123),
f.Format(" as hexadecimal: '%x'", 123),
f.Format("as hexadecimal, uppercase: '%X'", 123),
f.Format(" as octal: '%o'", 123),
f.Format("%nFloats:"),
f.Repeat("=-", 30),
f.Format(" normal: '%f'", 123.456789),
f.Format(" 2 decimals: '%.2f'", 123.456789),
f.Format(" scientific notation: '%e'", 123.456789),
f.Format("scientific notation, 2 decimals: '%.2e'", 123.456789),
f.Format(" scientific notation, uppercase: '%E'", 123.456789),
f.Format(" %%g: '%g'", 123.456789),
f.Format(" %%g, 2 decimals: '%.2g'", 123.456789),
f.Format(" %%G: '%g'", 123.456789),
f.Format(" %%G, 2 decimals: '%.2g'", 123.456789),
f.Format("%nStrings:"),
f.Repeat("-=", 30),
f.Format(" normal: '%s'", "Fauna"),
f.Format("uppercase: '%S'", "Fauna"),
f.Format(" null: '%s'", f.Null()),
f.Format(" %%%%: '%%'"),
f.Format("linefeed: %n"),
f.Format("%nBooleans:"),
f.Repeat("=-", 30),
f.Format(" true: '%b'", true),
f.Format(" true, uppercase: '%B'", 1),
f.Format(" false: '%b'", false),
f.Format("false, uppercase: '%B'", 0),
f.Format("%nTimes and Dates:"),
f.Repeat("-=", 30),
f.Format(" ISO-8601: %t", f.Var("ts")),
f.Format(" ISO-8601, uppercase: %T", f.Var("ts")),
f.Format(""),
f.Format(" Full month name: %tB", f.Var("ts")),
f.Format(" Full month name, uppercase: %TB", f.Var("ts")),
f.Format(" Short month name: %tb", f.Var("ts")),
f.Format(" Short month name, uppercase: %Tb", f.Var("ts")),
f.Format(" %%h: %th", f.Var("ts")),
f.Format(" %%h, uppercase: %Tb", f.Var("ts")),
f.Format(" Full weekday: %tA", f.Var("ts")),
f.Format(" Full weekday, uppercase: %TA", f.Var("ts")),
f.Format(" Short weekday: %ta", f.Var("ts")),
f.Format(" Short weekday, uppercase: %Ta", f.Var("ts")),
f.Format(" Century: %tC", f.Var("ts")),
f.Format(" Year: %tY", f.Var("ts")),
f.Format(" Short year: %ty", f.Var("ts")),
f.Format(" Day of the year: %tj", f.Var("ts")),
f.Format(" Month: %tm", f.Var("ts")),
f.Format(" Day of the month: %td", f.Var("ts")),
f.Format(""),
f.Format(" Hour, leading 0's (24): %tH", f.Var("ts")),
f.Format(" Hour, leading 0's (12): %tI", f.Var("ts")),
f.Format(" Hour (24): %tk", f.Var("ts")),
f.Format(" Hour (12): %tl", f.Var("ts")),
f.Format(" Minute: %tM", f.Var("ts")),
f.Format(" Second: %tS", f.Var("ts")),
f.Format(" Millisecond: %tL", f.Var("ts")),
f.Format(" Nanosecond: %tN", f.Var("ts")),
f.Format(" Morning/afternoon: %tp", f.Var("ts")),
f.Format("Morning/afternoon, uppercase: %Tp", f.Var("ts")),
f.Format(" Seconds since epoch: %ts", f.Var("ts")),
f.Format(" Milliseconds since epoch: %tQ", f.Var("ts")),
f.Format(""),
f.Format(" %%R: %tR", f.Var("ts")),
f.Format(" %%T: %tT", f.Var("ts")),
f.Format(" %%r: %tr", f.Var("ts")),
f.Format(" %%D: %tD", f.Var("ts")),
f.Format(" %%F: %tF", f.Var("ts")),
f.Format(" %%c: %tc", f.Var("ts")),
f.Format(""),
},
f.Separator("\n"),
),
),
)
System.out.println(
client.query(
Let(
Seq("ts" -> Time("2019-08-16T18:51:33.987654321+00:00")),
Concat(
Arr(
Format("%nDecimals:"),
Repeat("-=", 30),
Format(" normal: '%d'", 123),
Format(" with sign: '%+d'", 123),
Format(" with width: '%7d'", 123),
Format(" with width, align left: '%-7d'", 123),
Format(" as hexadecimal: '%x'", 123),
Format("as hexadecimal, uppercase: '%X'", 123),
Format(" as octal: '%o'", 123),
Format("%nFloats:"),
Repeat("=-", 30),
Format(" normal: '%f'", 123.456789),
Format(" 2 decimals: '%.2f'", 123.456789),
Format(" scientific notation: '%e'", 123.456789),
Format("scientific notation, 2 decimals: '%.2e'", 123.456789),
Format(" scientific notation, uppercase: '%E'", 123.456789),
Format(" %%g: '%g'", 123.456789),
Format(" %%g, 2 decimals: '%.2g'", 123.456789),
Format(" %%G: '%g'", 123.456789),
Format(" %%G, 2 decimals: '%.2g'", 123.456789),
Format("%nStrings:"),
Repeat("-=", 30),
Format(" normal: '%s'", "Fauna"),
Format("uppercase: '%S'", "Fauna"),
Format(" null: '%s'", Null),
Format(" %%%%: '%%'"),
Format("linefeed: %n"),
Format("%nBooleans:"),
Repeat("=-", 30),
Format(" true: '%b'", true),
Format(" true, uppercase: '%B'", 1),
Format(" false: '%b'", false),
Format("false, uppercase: '%B'", 0),
Format("%nTimes and Dates:"),
Repeat("-=", 30),
Format(" ISO-8601: %t", Var("ts")),
Format(" ISO-8601, uppercase: %T", Var("ts")),
Format(""),
Format(" Full month name: %tB", Var("ts")),
Format(" Full month name, uppercase: %TB", Var("ts")),
Format(" Short month name: %tb", Var("ts")),
Format(" Short month name, uppercase: %Tb", Var("ts")),
Format(" %%h: %th", Var("ts")),
Format(" %%h, uppercase: %Tb", Var("ts")),
Format(" Full weekday: %tA", Var("ts")),
Format(" Full weekday, uppercase: %TA", Var("ts")),
Format(" Short weekday: %ta", Var("ts")),
Format(" Short weekday, uppercase: %Ta", Var("ts")),
Format(" Century: %tC", Var("ts")),
Format(" Year: %tY", Var("ts")),
Format(" Short year: %ty", Var("ts")),
Format(" Day of the year: %tj", Var("ts")),
Format(" Month: %tm", Var("ts")),
Format(" Day of the month: %td", Var("ts")),
Format(""),
Format(" Hour, leading 0's (24): %tH", Var("ts")),
Format(" Hour, leading 0's (12): %tI", Var("ts")),
Format(" Hour (24): %tk", Var("ts")),
Format(" Hour (12): %tl", Var("ts")),
Format(" Minute: %tM", Var("ts")),
Format(" Second: %tS", Var("ts")),
Format(" Millisecond: %tL", Var("ts")),
Format(" Nanosecond: %tN", Var("ts")),
Format(" Morning/afternoon: %tp", Var("ts")),
Format("Morning/afternoon, uppercase: %Tp", Var("ts")),
Format(" Seconds since epoch: %ts", Var("ts")),
Format(" Milliseconds since epoch: %tQ", Var("ts")),
Format(""),
Format(" %%R: %tR", Var("ts")),
Format(" %%T: %tT", Var("ts")),
Format(" %%r: %tr", Var("ts")),
Format(" %%D: %tD", Var("ts")),
Format(" %%F: %tF", Var("ts")),
Format(" %%c: %tc", Var("ts")),
Format(""),
),
"\n"
)
)
).get());
client.query(
q.Let(
{ ts: q.Time('2019-08-16T18:51:33.987654321+00:00') },
q.Concat(
[
q.Format('%nDecimals:'),
q.Repeat('-=', 30),
q.Format(' normal: "%d"', 123),
q.Format(' with sign: "%+d"', 123),
q.Format(' with width: "%7d"', 123),
q.Format(' with width, align left: "%-7d"', 123),
q.Format(' as hexadecimal: "%x"', 123),
q.Format('as hexadecimal, uppercase: "%X"', 123),
q.Format(' as octal: "%o"', 123),
q.Format('%nFloats:'),
q.Repeat('=-', 30),
q.Format(' normal: "%f"', 123.456789),
q.Format(' 2 decimals: "%.2f"', 123.456789),
q.Format(' scientific notation: "%e"', 123.456789),
q.Format('scientific notation, 2 decimals: "%.2e"', 123.456789),
q.Format(' scientific notation, uppercase: "%E"', 123.456789),
q.Format(' %%g: "%g"', 123.456789),
q.Format(' %%g, 2 decimals: "%.2g"', 123.456789),
q.Format(' %%G: "%g"', 123.456789),
q.Format(' %%G, 2 decimals: "%.2g"', 123.456789),
q.Format('%nStrings:'),
q.Repeat('-=', 30),
q.Format(' normal: "%s"', 'Fauna'),
q.Format('uppercase: "%S"', 'Fauna'),
q.Format(' null: "%s"', null),
q.Format(' %%%%: "%%"'),
q.Format('linefeed: %n'),
q.Format('%nBooleans:'),
q.Repeat('=-', 30),
q.Format(' true: "%b"', true),
q.Format(' true, uppercase: "%B"', 1),
q.Format(' false: "%b"', false),
q.Format('false, uppercase: "%B"', 0),
q.Format('%nTimes and Dates:'),
q.Repeat('-=', 30),
q.Format(' ISO-8601: %t', q.Var('ts')),
q.Format(' ISO-8601, uppercase: %T', q.Var('ts')),
q.Format(''),
q.Format(' Full month name: %tB', q.Var('ts')),
q.Format(' Full month name, uppercase: %TB', q.Var('ts')),
q.Format(' Short month name: %tb', q.Var('ts')),
q.Format(' Short month name, uppercase: %Tb', q.Var('ts')),
q.Format(' %%h: %th', q.Var('ts')),
q.Format(' %%h, uppercase: %Tb', q.Var('ts')),
q.Format(' Full weekday: %tA', q.Var('ts')),
q.Format(' Full weekday, uppercase: %TA', q.Var('ts')),
q.Format(' Short weekday: %ta', q.Var('ts')),
q.Format(' Short weekday, uppercase: %Ta', q.Var('ts')),
q.Format(' Century: %tC', q.Var('ts')),
q.Format(' Year: %tY', q.Var('ts')),
q.Format(' Short year: %ty', q.Var('ts')),
q.Format(' Day of the year: %tj', q.Var('ts')),
q.Format(' Month: %tm', q.Var('ts')),
q.Format(' Day of the month: %td', q.Var('ts')),
q.Format(''),
q.Format(' Hour, leading 0\'s (24): %tH', q.Var('ts')),
q.Format(' Hour, leading 0\'s (12): %tI', q.Var('ts')),
q.Format(' Hour (24): %tk', q.Var('ts')),
q.Format(' Hour (12): %tl', q.Var('ts')),
q.Format(' Minute: %tM', q.Var('ts')),
q.Format(' Second: %tS', q.Var('ts')),
q.Format(' Millisecond: %tL', q.Var('ts')),
q.Format(' Nanosecond: %tN', q.Var('ts')),
q.Format(' Morning/afternoon: %tp', q.Var('ts')),
q.Format('Morning/afternoon, uppercase: %Tp', q.Var('ts')),
q.Format(' Seconds since epoch: %ts', q.Var('ts')),
q.Format(' Milliseconds since epoch: %tQ', q.Var('ts')),
q.Format(''),
q.Format(' %%R: %tR', q.Var('ts')),
q.Format(' %%T: %tT', q.Var('ts')),
q.Format(' %%r: %tr', q.Var('ts')),
q.Format(' %%D: %tD', q.Var('ts')),
q.Format(' %%F: %tF', q.Var('ts')),
q.Format(' %%c: %tc', q.Var('ts')),
q.Format(''),
],
'\n'
)
)
)
.then((ret) => console.log(ret))
result = client.query(
q.let(
{ "ts": q.time("2019-08-16T18:51:33.987654321+00:00") },
q.concat(
[
q.format("%nDecimals:"),
q.repeat("-=", 30),
q.format(" normal: '%d'", 123),
q.format(" with sign: '%+d'", 123),
q.format(" with width: '%7d'", 123),
q.format(" with width, align left: '%-7d'", 123),
q.format(" as hexadecimal: '%x'", 123),
q.format("as hexadecimal, uppercase: '%X'", 123),
q.format(" as octal: '%o'", 123),
q.format("%nFloats:"),
q.repeat("=-", 30),
q.format(" normal: '%f'", 123.456789),
q.format(" 2 decimals: '%.2f'", 123.456789),
q.format(" scientific notation: '%e'", 123.456789),
q.format("scientific notation, 2 decimals: '%.2e'", 123.456789),
q.format(" scientific notation, uppercase: '%E'", 123.456789),
q.format(" %%g: '%g'", 123.456789),
q.format(" %%g, 2 decimals: '%.2g'", 123.456789),
q.format(" %%G: '%g'", 123.456789),
q.format(" %%G, 2 decimals: '%.2g'", 123.456789),
q.format("%nStrings:"),
q.repeat("-=", 30),
q.format(" normal: '%s'", "Fauna"),
q.format("uppercase: '%S'", "Fauna"),
q.format(" null: '%s'", None),
q.format(" %%%%: '%%'"),
q.format("linefeed: %n"),
q.format("%nBooleans:"),
q.repeat("=-", 30),
q.format(" true: '%b'", True),
q.format(" true, uppercase: '%B'", 1),
q.format(" false: '%b'", False),
q.format("false, uppercase: '%B'", 0),
q.format("%nTimes and Dates:"),
q.repeat("-=", 30),
q.format(" ISO-8601: %t", q.var("ts")),
q.format(" ISO-8601, uppercase: %T", q.var("ts")),
q.format(""),
q.format(" Full month name: %tB", q.var("ts")),
q.format(" Full month name, uppercase: %TB", q.var("ts")),
q.format(" Short month name: %tb", q.var("ts")),
q.format(" Short month name, uppercase: %Tb", q.var("ts")),
q.format(" %%h: %th", q.var("ts")),
q.format(" %%h, uppercase: %Tb", q.var("ts")),
q.format(" Full weekday: %tA", q.var("ts")),
q.format(" Full weekday, uppercase: %TA", q.var("ts")),
q.format(" Short weekday: %ta", q.var("ts")),
q.format(" Short weekday, uppercase: %Ta", q.var("ts")),
q.format(" Century: %tC", q.var("ts")),
q.format(" Year: %tY", q.var("ts")),
q.format(" Short year: %ty", q.var("ts")),
q.format(" Day of the year: %tj", q.var("ts")),
q.format(" Month: %tm", q.var("ts")),
q.format(" Day of the month: %td", q.var("ts")),
q.format(""),
q.format(" Hour, leading 0's (24): %tH", q.var("ts")),
q.format(" Hour, leading 0's (12): %tI", q.var("ts")),
q.format(" Hour (24): %tk", q.var("ts")),
q.format(" Hour (12): %tl", q.var("ts")),
q.format(" Minute: %tM", q.var("ts")),
q.format(" Second: %tS", q.var("ts")),
q.format(" Millisecond: %tL", q.var("ts")),
q.format(" Nanosecond: %tN", q.var("ts")),
q.format(" Morning/afternoon: %tp", q.var("ts")),
q.format("Morning/afternoon, uppercase: %Tp", q.var("ts")),
q.format(" Seconds since epoch: %ts", q.var("ts")),
q.format(" Milliseconds since epoch: %tQ", q.var("ts")),
q.format(""),
q.format(" %%R: %tR", q.var("ts")),
q.format(" %%T: %tT", q.var("ts")),
q.format(" %%r: %tr", q.var("ts")),
q.format(" %%D: %tD", q.var("ts")),
q.format(" %%F: %tF", q.var("ts")),
q.format(" %%c: %tc", q.var("ts")),
q.format(""),
],
"\n"
)
)
)
print(result)
Not available in this language yet.
println(Await.result(
client.query(
Let(
Seq("ts" -> Time("2019-08-16T18:51:33.987654321+00:00")),
Concat(
Arr(
Format("%nDecimals:"),
Repeat("-=", 30),
Format(" normal: '%d'", 123),
Format(" with sign: '%+d'", 123),
Format(" with width: '%7d'", 123),
Format(" with width, align left: '%-7d'", 123),
Format(" as hexadecimal: '%x'", 123),
Format("as hexadecimal, uppercase: '%X'", 123),
Format(" as octal: '%o'", 123),
Format("%nFloats:"),
Repeat("=-", 30),
Format(" normal: '%f'", 123.456789),
Format(" 2 decimals: '%.2f'", 123.456789),
Format(" scientific notation: '%e'", 123.456789),
Format("scientific notation, 2 decimals: '%.2e'", 123.456789),
Format(" scientific notation, uppercase: '%E'", 123.456789),
Format(" %%g: '%g'", 123.456789),
Format(" %%g, 2 decimals: '%.2g'", 123.456789),
Format(" %%G: '%g'", 123.456789),
Format(" %%G, 2 decimals: '%.2g'", 123.456789),
Format("%nStrings:"),
Repeat("-=", 30),
Format(" normal: '%s'", "Fauna"),
Format("uppercase: '%S'", "Fauna"),
Format(" null: '%s'", Null),
Format(" %%%%: '%%'"),
Format("linefeed: %n"),
Format("%nBooleans:"),
Repeat("=-", 30),
Format(" true: '%b'", true),
Format(" true, uppercase: '%B'", 1),
Format(" false: '%b'", false),
Format("false, uppercase: '%B'", 0),
Format("%nTimes and Dates:"),
Repeat("-=", 30),
Format(" ISO-8601: %t", Var("ts")),
Format(" ISO-8601, uppercase: %T", Var("ts")),
Format(""),
Format(" Full month name: %tB", Var("ts")),
Format(" Full month name, uppercase: %TB", Var("ts")),
Format(" Short month name: %tb", Var("ts")),
Format(" Short month name, uppercase: %Tb", Var("ts")),
Format(" %%h: %th", Var("ts")),
Format(" %%h, uppercase: %Tb", Var("ts")),
Format(" Full weekday: %tA", Var("ts")),
Format(" Full weekday, uppercase: %TA", Var("ts")),
Format(" Short weekday: %ta", Var("ts")),
Format(" Short weekday, uppercase: %Ta", Var("ts")),
Format(" Century: %tC", Var("ts")),
Format(" Year: %tY", Var("ts")),
Format(" Short year: %ty", Var("ts")),
Format(" Day of the year: %tj", Var("ts")),
Format(" Month: %tm", Var("ts")),
Format(" Day of the month: %td", Var("ts")),
Format(""),
Format(" Hour, leading 0's (24): %tH", Var("ts")),
Format(" Hour, leading 0's (12): %tI", Var("ts")),
Format(" Hour (24): %tk", Var("ts")),
Format(" Hour (12): %tl", Var("ts")),
Format(" Minute: %tM", Var("ts")),
Format(" Second: %tS", Var("ts")),
Format(" Millisecond: %tL", Var("ts")),
Format(" Nanosecond: %tN", Var("ts")),
Format(" Morning/afternoon: %tp", Var("ts")),
Format("Morning/afternoon, uppercase: %Tp", Var("ts")),
Format(" Seconds since epoch: %ts", Var("ts")),
Format(" Milliseconds since epoch: %tQ", Var("ts")),
Format(""),
Format(" %%R: %tR", Var("ts")),
Format(" %%T: %tT", Var("ts")),
Format(" %%r: %tr", Var("ts")),
Format(" %%D: %tD", Var("ts")),
Format(" %%F: %tF", Var("ts")),
Format(" %%c: %tc", Var("ts")),
Format(""),
),
"\n"
)
)
),
5.seconds
))
Not available in this language yet.
Decimals:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: '123'
with sign: '+123'
with width: ' 123'
with width, align left: '123 '
as hexadecimal: '7b'
as hexadecimal, uppercase: '7B'
as octal: '173'
Floats:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
normal: '123.456789'
2 decimals: '123.46'
scientific notation: '1.234568e+02'
scientific notation, 2 decimals: '1.23e+02'
scientific notation, uppercase: '1.234568E+02'
%g: '123.457'
%g, 2 decimals: '1.2e+02'
%G: '123.457'
%G, 2 decimals: '1.2e+02'
Strings:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: 'Fauna'
uppercase: 'FAUNA'
null: 'null'
%%: '%'
linefeed:
Booleans:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
true: 'true'
true, uppercase: 'TRUE'
false: 'false'
false, uppercase: 'TRUE'
Times and Dates:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ISO-8601: 2019-08-16T18:51:33.987654321Z
ISO-8601, uppercase: 2019-08-16T18:51:33.987654321Z
Full month name: August
Full month name, uppercase: AUGUST
Short month name: Aug
Short month name, uppercase: AUG
%h: Aug
%h, uppercase: AUG
Full weekday: Friday
Full weekday, uppercase: FRIDAY
Short weekday: Fri
Short weekday, uppercase: FRI
Century: 20
Year: 2019
Short year: 19
Day of the year: 228
Month: 08
Day of the month: 16
Hour, leading 0's (24): 18
Hour, leading 0's (12): 06
Hour (24): 18
Hour (12): 6
Minute: 51
Second: 33
Millisecond: 987
Nanosecond: 987654321
Morning/afternoon: pm
Morning/afternoon, uppercase: PM
Seconds since epoch: 1565981493
Milliseconds since epoch: 1565981493987
%R: 18:51
%T: 18:51:33
%r: 06:51:33 PM
%D: 08/16/19
%F: 2019-08-16
%c: Fri Aug 16 18:51:33 Z 2019
Decimals:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: '123'
with sign: '+123'
with width: ' 123'
with width, align left: '123 '
as hexadecimal: '7b'
as hexadecimal, uppercase: '7B'
as octal: '173'
Floats:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
normal: '123.456789'
2 decimals: '123.46'
scientific notation: '1.234568e+02'
scientific notation, 2 decimals: '1.23e+02'
scientific notation, uppercase: '1.234568E+02'
%g: '123.457'
%g, 2 decimals: '1.2e+02'
%G: '123.457'
%G, 2 decimals: '1.2e+02'
Strings:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: 'Fauna'
uppercase: 'FAUNA'
null: 'null'
%%: '%'
linefeed:
Booleans:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
true: 'true'
true, uppercase: 'TRUE'
false: 'false'
false, uppercase: 'TRUE'
Times and Dates:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ISO-8601: 2019-08-16T18:51:33.987654321Z
ISO-8601, uppercase: 2019-08-16T18:51:33.987654321Z
Full month name: August
Full month name, uppercase: AUGUST
Short month name: Aug
Short month name, uppercase: AUG
%h: Aug
%h, uppercase: AUG
Full weekday: Friday
Full weekday, uppercase: FRIDAY
Short weekday: Fri
Short weekday, uppercase: FRI
Century: 20
Year: 2019
Short year: 19
Day of the year: 228
Month: 08
Day of the month: 16
Hour, leading 0's (24): 18
Hour, leading 0's (12): 06
Hour (24): 18
Hour (12): 6
Minute: 51
Second: 33
Millisecond: 987
Nanosecond: 987654321
Morning/afternoon: pm
Morning/afternoon, uppercase: PM
Seconds since epoch: 1565981493
Milliseconds since epoch: 1565981493987
%R: 18:51
%T: 18:51:33
%r: 06:51:33 PM
%D: 08/16/19
%F: 2019-08-16
%c: Fri Aug 16 18:51:33 Z 2019
"
Decimals:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: '123'
with sign: '+123'
with width: ' 123'
with width, align left: '123 '
as hexadecimal: '7b'
as hexadecimal, uppercase: '7B'
as octal: '173'
Floats:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
normal: '123.456789'
2 decimals: '123.46'
scientific notation: '1.234568e+02'
scientific notation, 2 decimals: '1.23e+02'
scientific notation, uppercase: '1.234568E+02'
%g: '123.457'
%g, 2 decimals: '1.2e+02'
%G: '123.457'
%G, 2 decimals: '1.2e+02'
Strings:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: 'Fauna'
uppercase: 'FAUNA'
null: 'null'
%%: '%'
linefeed:
Booleans:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
true: 'true'
true, uppercase: 'TRUE'
false: 'false'
false, uppercase: 'TRUE'
Times and Dates:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ISO-8601: 2019-08-16T18:51:33.987654321Z
ISO-8601, uppercase: 2019-08-16T18:51:33.987654321Z
Full month name: August
Full month name, uppercase: AUGUST
Short month name: Aug
Short month name, uppercase: AUG
%h: Aug
%h, uppercase: AUG
Full weekday: Friday
Full weekday, uppercase: FRIDAY
Short weekday: Fri
Short weekday, uppercase: FRI
Century: 20
Year: 2019
Short year: 19
Day of the year: 228
Month: 08
Day of the month: 16
Hour, leading 0's (24): 18
Hour, leading 0's (12): 06
Hour (24): 18
Hour (12): 6
Minute: 51
Second: 33
Millisecond: 987
Nanosecond: 987654321
Morning/afternoon: pm
Morning/afternoon, uppercase: PM
Seconds since epoch: 1565981493
Milliseconds since epoch: 1565981493987
%R: 18:51
%T: 18:51:33
%r: 06:51:33 PM
%D: 08/16/19
%F: 2019-08-16
%c: Fri Aug 16 18:51:33 Z 2019
"
Decimals:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: '123'
with sign: '+123'
with width: ' 123'
with width, align left: '123 '
as hexadecimal: '7b'
as hexadecimal, uppercase: '7B'
as octal: '173'
Floats:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
normal: '123.456789'
2 decimals: '123.46'
scientific notation: '1.234568e+02'
scientific notation, 2 decimals: '1.23e+02'
scientific notation, uppercase: '1.234568E+02'
%g: '123.457'
%g, 2 decimals: '1.2e+02'
%G: '123.457'
%G, 2 decimals: '1.2e+02'
Strings:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: 'Fauna'
uppercase: 'FAUNA'
null: 'null'
%%: '%'
linefeed:
Booleans:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
true: 'true'
true, uppercase: 'TRUE'
false: 'false'
false, uppercase: 'TRUE'
Times and Dates:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ISO-8601: 2019-08-16T18:51:33.987654321Z
ISO-8601, uppercase: 2019-08-16T18:51:33.987654321Z
Full month name: August
Full month name, uppercase: AUGUST
Short month name: Aug
Short month name, uppercase: AUG
%h: Aug
%h, uppercase: AUG
Full weekday: Friday
Full weekday, uppercase: FRIDAY
Short weekday: Fri
Short weekday, uppercase: FRI
Century: 20
Year: 2019
Short year: 19
Day of the year: 228
Month: 08
Day of the month: 16
Hour, leading 0's (24): 18
Hour, leading 0's (12): 06
Hour (24): 18
Hour (12): 6
Minute: 51
Second: 33
Millisecond: 987
Nanosecond: 987654321
Morning/afternoon: pm
Morning/afternoon, uppercase: PM
Seconds since epoch: 1565981493
Milliseconds since epoch: 1565981493987
%R: 18:51
%T: 18:51:33
%r: 06:51:33 PM
%D: 08/16/19
%F: 2019-08-16
%c: Fri Aug 16 18:51:33 Z 2019
Decimals:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: '123'
with sign: '+123'
with width: ' 123'
with width, align left: '123 '
as hexadecimal: '7b'
as hexadecimal, uppercase: '7B'
as octal: '173'
Floats:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
normal: '123.456789'
2 decimals: '123.46'
scientific notation: '1.234568e+02'
scientific notation, 2 decimals: '1.23e+02'
scientific notation, uppercase: '1.234568E+02'
%g: '123.457'
%g, 2 decimals: '1.2e+02'
%G: '123.457'
%G, 2 decimals: '1.2e+02'
Strings:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: 'Fauna'
uppercase: 'FAUNA'
null: 'null'
%%: '%'
linefeed:
Booleans:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
true: 'true'
true, uppercase: 'TRUE'
false: 'false'
false, uppercase: 'TRUE'
Times and Dates:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ISO-8601: 2019-08-16T18:51:33.987654321Z
ISO-8601, uppercase: 2019-08-16T18:51:33.987654321Z
Full month name: August
Full month name, uppercase: AUGUST
Short month name: Aug
Short month name, uppercase: AUG
%h: Aug
%h, uppercase: AUG
Full weekday: Friday
Full weekday, uppercase: FRIDAY
Short weekday: Fri
Short weekday, uppercase: FRI
Century: 20
Year: 2019
Short year: 19
Day of the year: 228
Month: 08
Day of the month: 16
Hour, leading 0's (24): 18
Hour, leading 0's (12): 06
Hour (24): 18
Hour (12): 6
Minute: 51
Second: 33
Millisecond: 987
Nanosecond: 987654321
Morning/afternoon: pm
Morning/afternoon, uppercase: PM
Seconds since epoch: 1565981493
Milliseconds since epoch: 1565981493987
%R: 18:51
%T: 18:51:33
%r: 06:51:33 PM
%D: 08/16/19
%F: 2019-08-16
%c: Fri Aug 16 18:51:33 Z 2019
"
Decimals:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: '123'
with sign: '+123'
with width: ' 123'
with width, align left: '123 '
as hexadecimal: '7b'
as hexadecimal, uppercase: '7B'
as octal: '173'
Floats:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
normal: '123.456789'
2 decimals: '123.46'
scientific notation: '1.234568e+02'
scientific notation, 2 decimals: '1.23e+02'
scientific notation, uppercase: '1.234568E+02'
%g: '123.457'
%g, 2 decimals: '1.2e+02'
%G: '123.457'
%G, 2 decimals: '1.2e+02'
Strings:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
normal: 'Fauna'
uppercase: 'FAUNA'
null: 'null'
%%: '%'
linefeed:
Booleans:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
true: 'true'
true, uppercase: 'TRUE'
false: 'false'
false, uppercase: 'TRUE'
Times and Dates:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ISO-8601: 2019-08-16T18:51:33.987654321Z
ISO-8601, uppercase: 2019-08-16T18:51:33.987654321Z
Full month name: August
Full month name, uppercase: AUGUST
Short month name: Aug
Short month name, uppercase: AUG
%h: Aug
%h, uppercase: AUG
Full weekday: Friday
Full weekday, uppercase: FRIDAY
Short weekday: Fri
Short weekday, uppercase: FRI
Century: 20
Year: 2019
Short year: 19
Day of the year: 228
Month: 08
Day of the month: 16
Hour, leading 0's (24): 18
Hour, leading 0's (12): 06
Hour (24): 18
Hour (12): 6
Minute: 51
Second: 33
Millisecond: 987
Nanosecond: 987654321
Morning/afternoon: pm
Morning/afternoon, uppercase: PM
Seconds since epoch: 1565981493
Milliseconds since epoch: 1565981493987
%R: 18:51
%T: 18:51:33
%r: 06:51:33 PM
%D: 08/16/19
%F: 2019-08-16
%c: Fri Aug 16 18:51:33 Z 2019
"
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!