1*5c90c05cSAndroid Build Coastguard Worker# Format String Syntax 2*5c90c05cSAndroid Build Coastguard Worker 3*5c90c05cSAndroid Build Coastguard WorkerFormatting functions such as [`fmt::format`](api.md#format) and [`fmt::print`]( 4*5c90c05cSAndroid Build Coastguard Workerapi.md#print) use the same format string syntax described in this section. 5*5c90c05cSAndroid Build Coastguard Worker 6*5c90c05cSAndroid Build Coastguard WorkerFormat strings contain "replacement fields" surrounded by curly braces `{}`. 7*5c90c05cSAndroid Build Coastguard WorkerAnything that is not contained in braces is considered literal text, which is 8*5c90c05cSAndroid Build Coastguard Workercopied unchanged to the output. If you need to include a brace character in 9*5c90c05cSAndroid Build Coastguard Workerthe literal text, it can be escaped by doubling: `{{` and `}}`. 10*5c90c05cSAndroid Build Coastguard Worker 11*5c90c05cSAndroid Build Coastguard WorkerThe grammar for a replacement field is as follows: 12*5c90c05cSAndroid Build Coastguard Worker 13*5c90c05cSAndroid Build Coastguard Worker<a id="replacement-field"></a> 14*5c90c05cSAndroid Build Coastguard Worker<pre><code class="language-json" 15*5c90c05cSAndroid Build Coastguard Worker>replacement_field ::= "{" [arg_id] [":" (<a href="#format-spec" 16*5c90c05cSAndroid Build Coastguard Worker >format_spec</a> | <a href="#chrono-format-spec">chrono_format_spec</a>)] "}" 17*5c90c05cSAndroid Build Coastguard Workerarg_id ::= integer | identifier 18*5c90c05cSAndroid Build Coastguard Workerinteger ::= digit+ 19*5c90c05cSAndroid Build Coastguard Workerdigit ::= "0"..."9" 20*5c90c05cSAndroid Build Coastguard Workeridentifier ::= id_start id_continue* 21*5c90c05cSAndroid Build Coastguard Workerid_start ::= "a"..."z" | "A"..."Z" | "_" 22*5c90c05cSAndroid Build Coastguard Workerid_continue ::= id_start | digit</code> 23*5c90c05cSAndroid Build Coastguard Worker</pre> 24*5c90c05cSAndroid Build Coastguard Worker 25*5c90c05cSAndroid Build Coastguard WorkerIn less formal terms, the replacement field can start with an *arg_id* that 26*5c90c05cSAndroid Build Coastguard Workerspecifies the argument whose value is to be formatted and inserted into the 27*5c90c05cSAndroid Build Coastguard Workeroutput instead of the replacement field. The *arg_id* is optionally followed 28*5c90c05cSAndroid Build Coastguard Workerby a *format_spec*, which is preceded by a colon `':'`. These specify a 29*5c90c05cSAndroid Build Coastguard Workernon-default format for the replacement value. 30*5c90c05cSAndroid Build Coastguard Worker 31*5c90c05cSAndroid Build Coastguard WorkerSee also the [Format Specification 32*5c90c05cSAndroid Build Coastguard WorkerMini-Language](#format-specification-mini-language) section. 33*5c90c05cSAndroid Build Coastguard Worker 34*5c90c05cSAndroid Build Coastguard WorkerIf the numerical arg_ids in a format string are 0, 1, 2, ... in sequence, 35*5c90c05cSAndroid Build Coastguard Workerthey can all be omitted (not just some) and the numbers 0, 1, 2, ... will be 36*5c90c05cSAndroid Build Coastguard Workerautomatically inserted in that order. 37*5c90c05cSAndroid Build Coastguard Worker 38*5c90c05cSAndroid Build Coastguard WorkerNamed arguments can be referred to by their names or indices. 39*5c90c05cSAndroid Build Coastguard Worker 40*5c90c05cSAndroid Build Coastguard WorkerSome simple format string examples: 41*5c90c05cSAndroid Build Coastguard Worker 42*5c90c05cSAndroid Build Coastguard Worker```c++ 43*5c90c05cSAndroid Build Coastguard Worker"First, thou shalt count to {0}" // References the first argument 44*5c90c05cSAndroid Build Coastguard Worker"Bring me a {}" // Implicitly references the first argument 45*5c90c05cSAndroid Build Coastguard Worker"From {} to {}" // Same as "From {0} to {1}" 46*5c90c05cSAndroid Build Coastguard Worker``` 47*5c90c05cSAndroid Build Coastguard Worker 48*5c90c05cSAndroid Build Coastguard WorkerThe *format_spec* field contains a specification of how the value should 49*5c90c05cSAndroid Build Coastguard Workerbe presented, including such details as field width, alignment, padding, 50*5c90c05cSAndroid Build Coastguard Workerdecimal precision and so on. Each value type can define its own 51*5c90c05cSAndroid Build Coastguard Worker"formatting mini-language" or interpretation of the *format_spec*. 52*5c90c05cSAndroid Build Coastguard Worker 53*5c90c05cSAndroid Build Coastguard WorkerMost built-in types support a common formatting mini-language, which is 54*5c90c05cSAndroid Build Coastguard Workerdescribed in the next section. 55*5c90c05cSAndroid Build Coastguard Worker 56*5c90c05cSAndroid Build Coastguard WorkerA *format_spec* field can also include nested replacement fields in 57*5c90c05cSAndroid Build Coastguard Workercertain positions within it. These nested replacement fields can contain 58*5c90c05cSAndroid Build Coastguard Workeronly an argument id; format specifications are not allowed. This allows 59*5c90c05cSAndroid Build Coastguard Workerthe formatting of a value to be dynamically specified. 60*5c90c05cSAndroid Build Coastguard Worker 61*5c90c05cSAndroid Build Coastguard WorkerSee the [Format Examples](#format-examples) section for some examples. 62*5c90c05cSAndroid Build Coastguard Worker 63*5c90c05cSAndroid Build Coastguard Worker## Format Specification Mini-Language 64*5c90c05cSAndroid Build Coastguard Worker 65*5c90c05cSAndroid Build Coastguard Worker"Format specifications" are used within replacement fields contained within a 66*5c90c05cSAndroid Build Coastguard Workerformat string to define how individual values are presented. Each formattable 67*5c90c05cSAndroid Build Coastguard Workertype may define how the format specification is to be interpreted. 68*5c90c05cSAndroid Build Coastguard Worker 69*5c90c05cSAndroid Build Coastguard WorkerMost built-in types implement the following options for format 70*5c90c05cSAndroid Build Coastguard Workerspecifications, although some of the formatting options are only 71*5c90c05cSAndroid Build Coastguard Workersupported by the numeric types. 72*5c90c05cSAndroid Build Coastguard Worker 73*5c90c05cSAndroid Build Coastguard WorkerThe general form of a *standard format specifier* is: 74*5c90c05cSAndroid Build Coastguard Worker 75*5c90c05cSAndroid Build Coastguard Worker<a id="format-spec"></a> 76*5c90c05cSAndroid Build Coastguard Worker<pre><code class="language-json" 77*5c90c05cSAndroid Build Coastguard Worker>format_spec ::= [[fill]align][sign]["#"]["0"][width]["." precision]["L"][type] 78*5c90c05cSAndroid Build Coastguard Workerfill ::= <a character other than '{' or '}'> 79*5c90c05cSAndroid Build Coastguard Workeralign ::= "<" | ">" | "^" 80*5c90c05cSAndroid Build Coastguard Workersign ::= "+" | "-" | " " 81*5c90c05cSAndroid Build Coastguard Workerwidth ::= <a href="#replacement-field">integer</a> | "{" [<a 82*5c90c05cSAndroid Build Coastguard Worker href="#replacement-field">arg_id</a>] "}" 83*5c90c05cSAndroid Build Coastguard Workerprecision ::= <a href="#replacement-field">integer</a> | "{" [<a 84*5c90c05cSAndroid Build Coastguard Worker href="#replacement-field">arg_id</a>] "}" 85*5c90c05cSAndroid Build Coastguard Workertype ::= "a" | "A" | "b" | "B" | "c" | "d" | "e" | "E" | "f" | "F" | 86*5c90c05cSAndroid Build Coastguard Worker "g" | "G" | "o" | "p" | "s" | "x" | "X" | "?"</code> 87*5c90c05cSAndroid Build Coastguard Worker</pre> 88*5c90c05cSAndroid Build Coastguard Worker 89*5c90c05cSAndroid Build Coastguard WorkerThe *fill* character can be any Unicode code point other than `'{'` or `'}'`. 90*5c90c05cSAndroid Build Coastguard WorkerThe presence of a fill character is signaled by the character following it, 91*5c90c05cSAndroid Build Coastguard Workerwhich must be one of the alignment options. If the second character of 92*5c90c05cSAndroid Build Coastguard Worker*format_spec* is not a valid alignment option, then it is assumed that both 93*5c90c05cSAndroid Build Coastguard Workerthe fill character and the alignment option are absent. 94*5c90c05cSAndroid Build Coastguard Worker 95*5c90c05cSAndroid Build Coastguard WorkerThe meaning of the various alignment options is as follows: 96*5c90c05cSAndroid Build Coastguard Worker 97*5c90c05cSAndroid Build Coastguard Worker<table> 98*5c90c05cSAndroid Build Coastguard Worker<tr> 99*5c90c05cSAndroid Build Coastguard Worker <th>Option</th> 100*5c90c05cSAndroid Build Coastguard Worker <th>Meaning</th> 101*5c90c05cSAndroid Build Coastguard Worker</tr> 102*5c90c05cSAndroid Build Coastguard Worker<tr> 103*5c90c05cSAndroid Build Coastguard Worker <td><code>'<'</code></td> 104*5c90c05cSAndroid Build Coastguard Worker <td> 105*5c90c05cSAndroid Build Coastguard Worker Forces the field to be left-aligned within the available space (this is the 106*5c90c05cSAndroid Build Coastguard Worker default for most objects). 107*5c90c05cSAndroid Build Coastguard Worker </td> 108*5c90c05cSAndroid Build Coastguard Worker</tr> 109*5c90c05cSAndroid Build Coastguard Worker<tr> 110*5c90c05cSAndroid Build Coastguard Worker <td><code>'>'</code></td> 111*5c90c05cSAndroid Build Coastguard Worker <td> 112*5c90c05cSAndroid Build Coastguard Worker Forces the field to be right-aligned within the available space (this is 113*5c90c05cSAndroid Build Coastguard Worker the default for numbers). 114*5c90c05cSAndroid Build Coastguard Worker </td> 115*5c90c05cSAndroid Build Coastguard Worker</tr> 116*5c90c05cSAndroid Build Coastguard Worker<tr> 117*5c90c05cSAndroid Build Coastguard Worker <td><code>'^'</code></td> 118*5c90c05cSAndroid Build Coastguard Worker <td>Forces the field to be centered within the available space.</td> 119*5c90c05cSAndroid Build Coastguard Worker</tr> 120*5c90c05cSAndroid Build Coastguard Worker</table> 121*5c90c05cSAndroid Build Coastguard Worker 122*5c90c05cSAndroid Build Coastguard WorkerNote that unless a minimum field width is defined, the field width will 123*5c90c05cSAndroid Build Coastguard Workeralways be the same size as the data to fill it, so that the alignment 124*5c90c05cSAndroid Build Coastguard Workeroption has no meaning in this case. 125*5c90c05cSAndroid Build Coastguard Worker 126*5c90c05cSAndroid Build Coastguard WorkerThe *sign* option is only valid for floating point and signed integer types, 127*5c90c05cSAndroid Build Coastguard Workerand can be one of the following: 128*5c90c05cSAndroid Build Coastguard Worker 129*5c90c05cSAndroid Build Coastguard Worker<table> 130*5c90c05cSAndroid Build Coastguard Worker<tr> 131*5c90c05cSAndroid Build Coastguard Worker <th>Option</th> 132*5c90c05cSAndroid Build Coastguard Worker <th>Meaning</th> 133*5c90c05cSAndroid Build Coastguard Worker</tr> 134*5c90c05cSAndroid Build Coastguard Worker<tr> 135*5c90c05cSAndroid Build Coastguard Worker <td><code>'+'</code></td> 136*5c90c05cSAndroid Build Coastguard Worker <td> 137*5c90c05cSAndroid Build Coastguard Worker Indicates that a sign should be used for both nonnegative as well as 138*5c90c05cSAndroid Build Coastguard Worker negative numbers. 139*5c90c05cSAndroid Build Coastguard Worker </td> 140*5c90c05cSAndroid Build Coastguard Worker</tr> 141*5c90c05cSAndroid Build Coastguard Worker<tr> 142*5c90c05cSAndroid Build Coastguard Worker <td><code>'-'</code></td> 143*5c90c05cSAndroid Build Coastguard Worker <td> 144*5c90c05cSAndroid Build Coastguard Worker Indicates that a sign should be used only for negative numbers (this is the 145*5c90c05cSAndroid Build Coastguard Worker default behavior). 146*5c90c05cSAndroid Build Coastguard Worker </td> 147*5c90c05cSAndroid Build Coastguard Worker</tr> 148*5c90c05cSAndroid Build Coastguard Worker<tr> 149*5c90c05cSAndroid Build Coastguard Worker <td>space</td> 150*5c90c05cSAndroid Build Coastguard Worker <td> 151*5c90c05cSAndroid Build Coastguard Worker Indicates that a leading space should be used on nonnegative numbers, and a 152*5c90c05cSAndroid Build Coastguard Worker minus sign on negative numbers. 153*5c90c05cSAndroid Build Coastguard Worker </td> 154*5c90c05cSAndroid Build Coastguard Worker</tr> 155*5c90c05cSAndroid Build Coastguard Worker</table> 156*5c90c05cSAndroid Build Coastguard Worker 157*5c90c05cSAndroid Build Coastguard WorkerThe `'#'` option causes the "alternate form" to be used for the 158*5c90c05cSAndroid Build Coastguard Workerconversion. The alternate form is defined differently for different 159*5c90c05cSAndroid Build Coastguard Workertypes. This option is only valid for integer and floating-point types. 160*5c90c05cSAndroid Build Coastguard WorkerFor integers, when binary, octal, or hexadecimal output is used, this 161*5c90c05cSAndroid Build Coastguard Workeroption adds the prefix respective `"0b"` (`"0B"`), `"0"`, or `"0x"` 162*5c90c05cSAndroid Build Coastguard Worker(`"0X"`) to the output value. Whether the prefix is lower-case or 163*5c90c05cSAndroid Build Coastguard Workerupper-case is determined by the case of the type specifier, for example, 164*5c90c05cSAndroid Build Coastguard Workerthe prefix `"0x"` is used for the type `'x'` and `"0X"` is used for 165*5c90c05cSAndroid Build Coastguard Worker`'X'`. For floating-point numbers the alternate form causes the result 166*5c90c05cSAndroid Build Coastguard Workerof the conversion to always contain a decimal-point character, even if 167*5c90c05cSAndroid Build Coastguard Workerno digits follow it. Normally, a decimal-point character appears in the 168*5c90c05cSAndroid Build Coastguard Workerresult of these conversions only if a digit follows it. In addition, for 169*5c90c05cSAndroid Build Coastguard Worker`'g'` and `'G'` conversions, trailing zeros are not removed from the 170*5c90c05cSAndroid Build Coastguard Workerresult. 171*5c90c05cSAndroid Build Coastguard Worker 172*5c90c05cSAndroid Build Coastguard Worker*width* is a decimal integer defining the minimum field width. If not 173*5c90c05cSAndroid Build Coastguard Workerspecified, then the field width will be determined by the content. 174*5c90c05cSAndroid Build Coastguard Worker 175*5c90c05cSAndroid Build Coastguard WorkerPreceding the *width* field by a zero (`'0'`) character enables 176*5c90c05cSAndroid Build Coastguard Workersign-aware zero-padding for numeric types. It forces the padding to be 177*5c90c05cSAndroid Build Coastguard Workerplaced after the sign or base (if any) but before the digits. This is 178*5c90c05cSAndroid Build Coastguard Workerused for printing fields in the form "+000000120". This option is only 179*5c90c05cSAndroid Build Coastguard Workervalid for numeric types and it has no effect on formatting of infinity 180*5c90c05cSAndroid Build Coastguard Workerand NaN. This option is ignored when any alignment specifier is present. 181*5c90c05cSAndroid Build Coastguard Worker 182*5c90c05cSAndroid Build Coastguard WorkerThe *precision* is a decimal number indicating how many digits should be 183*5c90c05cSAndroid Build Coastguard Workerdisplayed after the decimal point for a floating-point value formatted 184*5c90c05cSAndroid Build Coastguard Workerwith `'f'` and `'F'`, or before and after the decimal point for a 185*5c90c05cSAndroid Build Coastguard Workerfloating-point value formatted with `'g'` or `'G'`. For non-number types 186*5c90c05cSAndroid Build Coastguard Workerthe field indicates the maximum field size - in other words, how many 187*5c90c05cSAndroid Build Coastguard Workercharacters will be used from the field content. The *precision* is not 188*5c90c05cSAndroid Build Coastguard Workerallowed for integer, character, Boolean, and pointer values. Note that a 189*5c90c05cSAndroid Build Coastguard WorkerC string must be null-terminated even if precision is specified. 190*5c90c05cSAndroid Build Coastguard Worker 191*5c90c05cSAndroid Build Coastguard WorkerThe `'L'` option uses the current locale setting to insert the appropriate 192*5c90c05cSAndroid Build Coastguard Workernumber separator characters. This option is only valid for numeric types. 193*5c90c05cSAndroid Build Coastguard Worker 194*5c90c05cSAndroid Build Coastguard WorkerFinally, the *type* determines how the data should be presented. 195*5c90c05cSAndroid Build Coastguard Worker 196*5c90c05cSAndroid Build Coastguard WorkerThe available string presentation types are: 197*5c90c05cSAndroid Build Coastguard Worker 198*5c90c05cSAndroid Build Coastguard Worker<table> 199*5c90c05cSAndroid Build Coastguard Worker<tr> 200*5c90c05cSAndroid Build Coastguard Worker <th>Type</th> 201*5c90c05cSAndroid Build Coastguard Worker <th>Meaning</th> 202*5c90c05cSAndroid Build Coastguard Worker</tr> 203*5c90c05cSAndroid Build Coastguard Worker<tr> 204*5c90c05cSAndroid Build Coastguard Worker <td><code>'s'</code></td> 205*5c90c05cSAndroid Build Coastguard Worker <td> 206*5c90c05cSAndroid Build Coastguard Worker String format. This is the default type for strings and may be omitted. 207*5c90c05cSAndroid Build Coastguard Worker </td> 208*5c90c05cSAndroid Build Coastguard Worker</tr> 209*5c90c05cSAndroid Build Coastguard Worker<tr> 210*5c90c05cSAndroid Build Coastguard Worker <td><code>'?'</code></td> 211*5c90c05cSAndroid Build Coastguard Worker <td>Debug format. The string is quoted and special characters escaped.</td> 212*5c90c05cSAndroid Build Coastguard Worker</tr> 213*5c90c05cSAndroid Build Coastguard Worker<tr> 214*5c90c05cSAndroid Build Coastguard Worker <td>none</td> 215*5c90c05cSAndroid Build Coastguard Worker <td>The same as <code>'s'</code>.</td> 216*5c90c05cSAndroid Build Coastguard Worker</tr> 217*5c90c05cSAndroid Build Coastguard Worker</table> 218*5c90c05cSAndroid Build Coastguard Worker 219*5c90c05cSAndroid Build Coastguard WorkerThe available character presentation types are: 220*5c90c05cSAndroid Build Coastguard Worker 221*5c90c05cSAndroid Build Coastguard Worker<table> 222*5c90c05cSAndroid Build Coastguard Worker<tr> 223*5c90c05cSAndroid Build Coastguard Worker <th>Type</th> 224*5c90c05cSAndroid Build Coastguard Worker <th>Meaning</th> 225*5c90c05cSAndroid Build Coastguard Worker</tr> 226*5c90c05cSAndroid Build Coastguard Worker<tr> 227*5c90c05cSAndroid Build Coastguard Worker <td><code>'c'</code></td> 228*5c90c05cSAndroid Build Coastguard Worker <td> 229*5c90c05cSAndroid Build Coastguard Worker Character format. This is the default type for characters and may be 230*5c90c05cSAndroid Build Coastguard Worker omitted. 231*5c90c05cSAndroid Build Coastguard Worker </td> 232*5c90c05cSAndroid Build Coastguard Worker</tr> 233*5c90c05cSAndroid Build Coastguard Worker<tr> 234*5c90c05cSAndroid Build Coastguard Worker <td><code>'?'</code></td> 235*5c90c05cSAndroid Build Coastguard Worker <td>Debug format. The character is quoted and special characters escaped.</td> 236*5c90c05cSAndroid Build Coastguard Worker</tr> 237*5c90c05cSAndroid Build Coastguard Worker<tr> 238*5c90c05cSAndroid Build Coastguard Worker <td>none</td> 239*5c90c05cSAndroid Build Coastguard Worker <td>The same as <code>'c'</code>.</td> 240*5c90c05cSAndroid Build Coastguard Worker</tr> 241*5c90c05cSAndroid Build Coastguard Worker</table> 242*5c90c05cSAndroid Build Coastguard Worker 243*5c90c05cSAndroid Build Coastguard WorkerThe available integer presentation types are: 244*5c90c05cSAndroid Build Coastguard Worker 245*5c90c05cSAndroid Build Coastguard Worker<table> 246*5c90c05cSAndroid Build Coastguard Worker<tr> 247*5c90c05cSAndroid Build Coastguard Worker <th>Type</th> 248*5c90c05cSAndroid Build Coastguard Worker <th>Meaning</th> 249*5c90c05cSAndroid Build Coastguard Worker</tr> 250*5c90c05cSAndroid Build Coastguard Worker<tr> 251*5c90c05cSAndroid Build Coastguard Worker <td><code>'b'</code></td> 252*5c90c05cSAndroid Build Coastguard Worker <td> 253*5c90c05cSAndroid Build Coastguard Worker Binary format. Outputs the number in base 2. Using the <code>'#'</code> 254*5c90c05cSAndroid Build Coastguard Worker option with this type adds the prefix <code>"0b"</code> to the output value. 255*5c90c05cSAndroid Build Coastguard Worker </td> 256*5c90c05cSAndroid Build Coastguard Worker</tr> 257*5c90c05cSAndroid Build Coastguard Worker<tr> 258*5c90c05cSAndroid Build Coastguard Worker <td><code>'B'</code></td> 259*5c90c05cSAndroid Build Coastguard Worker <td> 260*5c90c05cSAndroid Build Coastguard Worker Binary format. Outputs the number in base 2. Using the <code>'#'</code> 261*5c90c05cSAndroid Build Coastguard Worker option with this type adds the prefix <code>"0B"</code> to the output value. 262*5c90c05cSAndroid Build Coastguard Worker </td> 263*5c90c05cSAndroid Build Coastguard Worker</tr> 264*5c90c05cSAndroid Build Coastguard Worker<tr> 265*5c90c05cSAndroid Build Coastguard Worker <td><code>'c'</code></td> 266*5c90c05cSAndroid Build Coastguard Worker <td>Character format. Outputs the number as a character.</td> 267*5c90c05cSAndroid Build Coastguard Worker</tr> 268*5c90c05cSAndroid Build Coastguard Worker<tr> 269*5c90c05cSAndroid Build Coastguard Worker <td><code>'d'</code></td> 270*5c90c05cSAndroid Build Coastguard Worker <td>Decimal integer. Outputs the number in base 10.</td> 271*5c90c05cSAndroid Build Coastguard Worker</tr> 272*5c90c05cSAndroid Build Coastguard Worker<tr> 273*5c90c05cSAndroid Build Coastguard Worker <td><code>'o'</code></td> 274*5c90c05cSAndroid Build Coastguard Worker <td>Octal format. Outputs the number in base 8.</td> 275*5c90c05cSAndroid Build Coastguard Worker</tr> 276*5c90c05cSAndroid Build Coastguard Worker<tr> 277*5c90c05cSAndroid Build Coastguard Worker <td><code>'x'</code></td> 278*5c90c05cSAndroid Build Coastguard Worker <td> 279*5c90c05cSAndroid Build Coastguard Worker Hex format. Outputs the number in base 16, using lower-case letters for the 280*5c90c05cSAndroid Build Coastguard Worker digits above 9. Using the <code>'#'</code> option with this type adds the 281*5c90c05cSAndroid Build Coastguard Worker prefix <code>"0x"</code> to the output value. 282*5c90c05cSAndroid Build Coastguard Worker </td> 283*5c90c05cSAndroid Build Coastguard Worker</tr> 284*5c90c05cSAndroid Build Coastguard Worker<tr> 285*5c90c05cSAndroid Build Coastguard Worker <td><code>'X'</code></td> 286*5c90c05cSAndroid Build Coastguard Worker <td> 287*5c90c05cSAndroid Build Coastguard Worker Hex format. Outputs the number in base 16, using upper-case letters for the 288*5c90c05cSAndroid Build Coastguard Worker digits above 9. Using the <code>'#'</code> option with this type adds the 289*5c90c05cSAndroid Build Coastguard Worker prefix <code>"0X"</code> to the output value. 290*5c90c05cSAndroid Build Coastguard Worker </td> 291*5c90c05cSAndroid Build Coastguard Worker</tr> 292*5c90c05cSAndroid Build Coastguard Worker<tr> 293*5c90c05cSAndroid Build Coastguard Worker <td>none</td> 294*5c90c05cSAndroid Build Coastguard Worker <td>The same as <code>'d'</code>.</td> 295*5c90c05cSAndroid Build Coastguard Worker</tr> 296*5c90c05cSAndroid Build Coastguard Worker</table> 297*5c90c05cSAndroid Build Coastguard Worker 298*5c90c05cSAndroid Build Coastguard WorkerInteger presentation types can also be used with character and Boolean values 299*5c90c05cSAndroid Build Coastguard Workerwith the only exception that `'c'` cannot be used with `bool`. Boolean values 300*5c90c05cSAndroid Build Coastguard Workerare formatted using textual representation, either `true` or `false`, if the 301*5c90c05cSAndroid Build Coastguard Workerpresentation type is not specified. 302*5c90c05cSAndroid Build Coastguard Worker 303*5c90c05cSAndroid Build Coastguard WorkerThe available presentation types for floating-point values are: 304*5c90c05cSAndroid Build Coastguard Worker 305*5c90c05cSAndroid Build Coastguard Worker<table> 306*5c90c05cSAndroid Build Coastguard Worker<tr> 307*5c90c05cSAndroid Build Coastguard Worker <th>Type</th> 308*5c90c05cSAndroid Build Coastguard Worker <th>Meaning</th> 309*5c90c05cSAndroid Build Coastguard Worker</tr> 310*5c90c05cSAndroid Build Coastguard Worker<tr> 311*5c90c05cSAndroid Build Coastguard Worker <td><code>'a'</code></td> 312*5c90c05cSAndroid Build Coastguard Worker <td> 313*5c90c05cSAndroid Build Coastguard Worker Hexadecimal floating point format. Prints the number in base 16 with 314*5c90c05cSAndroid Build Coastguard Worker prefix <code>"0x"</code> and lower-case letters for digits above 9. 315*5c90c05cSAndroid Build Coastguard Worker Uses <code>'p'</code> to indicate the exponent. 316*5c90c05cSAndroid Build Coastguard Worker </td> 317*5c90c05cSAndroid Build Coastguard Worker</tr> 318*5c90c05cSAndroid Build Coastguard Worker<tr> 319*5c90c05cSAndroid Build Coastguard Worker <td><code>'A'</code></td> 320*5c90c05cSAndroid Build Coastguard Worker <td> 321*5c90c05cSAndroid Build Coastguard Worker Same as <code>'a'</code> except it uses upper-case letters for the 322*5c90c05cSAndroid Build Coastguard Worker prefix, digits above 9 and to indicate the exponent. 323*5c90c05cSAndroid Build Coastguard Worker </td> 324*5c90c05cSAndroid Build Coastguard Worker</tr> 325*5c90c05cSAndroid Build Coastguard Worker<tr> 326*5c90c05cSAndroid Build Coastguard Worker <td><code>'e'</code></td> 327*5c90c05cSAndroid Build Coastguard Worker <td> 328*5c90c05cSAndroid Build Coastguard Worker Exponent notation. Prints the number in scientific notation using 329*5c90c05cSAndroid Build Coastguard Worker the letter 'e' to indicate the exponent. 330*5c90c05cSAndroid Build Coastguard Worker </td> 331*5c90c05cSAndroid Build Coastguard Worker</tr> 332*5c90c05cSAndroid Build Coastguard Worker<tr> 333*5c90c05cSAndroid Build Coastguard Worker <td><code>'E'</code></td> 334*5c90c05cSAndroid Build Coastguard Worker <td> 335*5c90c05cSAndroid Build Coastguard Worker Exponent notation. Same as <code>'e'</code> except it uses an 336*5c90c05cSAndroid Build Coastguard Worker upper-case <code>'E'</code> as the separator character. 337*5c90c05cSAndroid Build Coastguard Worker </td> 338*5c90c05cSAndroid Build Coastguard Worker</tr> 339*5c90c05cSAndroid Build Coastguard Worker<tr> 340*5c90c05cSAndroid Build Coastguard Worker <td><code>'f'</code></td> 341*5c90c05cSAndroid Build Coastguard Worker <td>Fixed point. Displays the number as a fixed-point number.</td> 342*5c90c05cSAndroid Build Coastguard Worker</tr> 343*5c90c05cSAndroid Build Coastguard Worker<tr> 344*5c90c05cSAndroid Build Coastguard Worker <td><code>'F'</code></td> 345*5c90c05cSAndroid Build Coastguard Worker <td> 346*5c90c05cSAndroid Build Coastguard Worker Fixed point. Same as <code>'f'</code>, but converts <code>nan</code> 347*5c90c05cSAndroid Build Coastguard Worker to <code>NAN</code> and <code>inf</code> to <code>INF</code>. 348*5c90c05cSAndroid Build Coastguard Worker </td> 349*5c90c05cSAndroid Build Coastguard Worker</tr> 350*5c90c05cSAndroid Build Coastguard Worker<tr> 351*5c90c05cSAndroid Build Coastguard Worker <td><code>'g'</code></td> 352*5c90c05cSAndroid Build Coastguard Worker <td> 353*5c90c05cSAndroid Build Coastguard Worker <p>General format. For a given precision <code>p >= 1</code>, 354*5c90c05cSAndroid Build Coastguard Worker this rounds the number to <code>p</code> significant digits and then 355*5c90c05cSAndroid Build Coastguard Worker formats the result in either fixed-point format or in scientific 356*5c90c05cSAndroid Build Coastguard Worker notation, depending on its magnitude.</p> 357*5c90c05cSAndroid Build Coastguard Worker <p>A precision of <code>0</code> is treated as equivalent to a precision 358*5c90c05cSAndroid Build Coastguard Worker of <code>1</code>.</p> 359*5c90c05cSAndroid Build Coastguard Worker </td> 360*5c90c05cSAndroid Build Coastguard Worker</tr> 361*5c90c05cSAndroid Build Coastguard Worker<tr> 362*5c90c05cSAndroid Build Coastguard Worker <td><code>'G'</code></td> 363*5c90c05cSAndroid Build Coastguard Worker <td> 364*5c90c05cSAndroid Build Coastguard Worker General format. Same as <code>'g'</code> except switches to 365*5c90c05cSAndroid Build Coastguard Worker <code>'E'</code> if the number gets too large. The representations of 366*5c90c05cSAndroid Build Coastguard Worker infinity and NaN are uppercased, too. 367*5c90c05cSAndroid Build Coastguard Worker </td> 368*5c90c05cSAndroid Build Coastguard Worker</tr> 369*5c90c05cSAndroid Build Coastguard Worker<tr> 370*5c90c05cSAndroid Build Coastguard Worker <td>none</td> 371*5c90c05cSAndroid Build Coastguard Worker <td> 372*5c90c05cSAndroid Build Coastguard Worker Similar to <code>'g'</code>, except that the default precision is as 373*5c90c05cSAndroid Build Coastguard Worker high as needed to represent the particular value. 374*5c90c05cSAndroid Build Coastguard Worker </td> 375*5c90c05cSAndroid Build Coastguard Worker</tr> 376*5c90c05cSAndroid Build Coastguard Worker</table> 377*5c90c05cSAndroid Build Coastguard Worker 378*5c90c05cSAndroid Build Coastguard WorkerThe available presentation types for pointers are: 379*5c90c05cSAndroid Build Coastguard Worker 380*5c90c05cSAndroid Build Coastguard Worker<table> 381*5c90c05cSAndroid Build Coastguard Worker<tr> 382*5c90c05cSAndroid Build Coastguard Worker <th>Type</th> 383*5c90c05cSAndroid Build Coastguard Worker <th>Meaning</th> 384*5c90c05cSAndroid Build Coastguard Worker</tr> 385*5c90c05cSAndroid Build Coastguard Worker<tr> 386*5c90c05cSAndroid Build Coastguard Worker <td><code>'p'</code></td> 387*5c90c05cSAndroid Build Coastguard Worker <td> 388*5c90c05cSAndroid Build Coastguard Worker Pointer format. This is the default type for pointers and may be omitted. 389*5c90c05cSAndroid Build Coastguard Worker </td> 390*5c90c05cSAndroid Build Coastguard Worker</tr> 391*5c90c05cSAndroid Build Coastguard Worker<tr> 392*5c90c05cSAndroid Build Coastguard Worker <td>none</td> 393*5c90c05cSAndroid Build Coastguard Worker <td>The same as <code>'p'</code>.</td> 394*5c90c05cSAndroid Build Coastguard Worker</tr> 395*5c90c05cSAndroid Build Coastguard Worker</table> 396*5c90c05cSAndroid Build Coastguard Worker 397*5c90c05cSAndroid Build Coastguard Worker## Chrono Format Specifications 398*5c90c05cSAndroid Build Coastguard Worker 399*5c90c05cSAndroid Build Coastguard WorkerFormat specifications for chrono duration and time point types as well as 400*5c90c05cSAndroid Build Coastguard Worker`std::tm` have the following syntax: 401*5c90c05cSAndroid Build Coastguard Worker 402*5c90c05cSAndroid Build Coastguard Worker<a id="chrono-format-spec"></a> 403*5c90c05cSAndroid Build Coastguard Worker<pre><code class="language-json" 404*5c90c05cSAndroid Build Coastguard Worker>chrono_format_spec ::= [[<a href="#format-spec">fill</a>]<a href="#format-spec" 405*5c90c05cSAndroid Build Coastguard Worker >align</a>][<a href="#format-spec">width</a>]["." <a href="#format-spec" 406*5c90c05cSAndroid Build Coastguard Worker >precision</a>][chrono_specs] 407*5c90c05cSAndroid Build Coastguard Workerchrono_specs ::= conversion_spec | 408*5c90c05cSAndroid Build Coastguard Worker chrono_specs (conversion_spec | literal_char) 409*5c90c05cSAndroid Build Coastguard Workerconversion_spec ::= "%" [padding_modifier] [locale_modifier] chrono_type 410*5c90c05cSAndroid Build Coastguard Workerliteral_char ::= <a character other than '{', '}' or '%'> 411*5c90c05cSAndroid Build Coastguard Workerpadding_modifier ::= "-" | "_" | "0" 412*5c90c05cSAndroid Build Coastguard Workerlocale_modifier ::= "E" | "O" 413*5c90c05cSAndroid Build Coastguard Workerchrono_type ::= "a" | "A" | "b" | "B" | "c" | "C" | "d" | "D" | "e" | 414*5c90c05cSAndroid Build Coastguard Worker "F" | "g" | "G" | "h" | "H" | "I" | "j" | "m" | "M" | 415*5c90c05cSAndroid Build Coastguard Worker "n" | "p" | "q" | "Q" | "r" | "R" | "S" | "t" | "T" | 416*5c90c05cSAndroid Build Coastguard Worker "u" | "U" | "V" | "w" | "W" | "x" | "X" | "y" | "Y" | 417*5c90c05cSAndroid Build Coastguard Worker "z" | "Z" | "%"</code> 418*5c90c05cSAndroid Build Coastguard Worker</pre> 419*5c90c05cSAndroid Build Coastguard Worker 420*5c90c05cSAndroid Build Coastguard WorkerLiteral chars are copied unchanged to the output. Precision is valid only 421*5c90c05cSAndroid Build Coastguard Workerfor `std::chrono::duration` types with a floating-point representation type. 422*5c90c05cSAndroid Build Coastguard Worker 423*5c90c05cSAndroid Build Coastguard WorkerThe available presentation types (*chrono_type*) are: 424*5c90c05cSAndroid Build Coastguard Worker 425*5c90c05cSAndroid Build Coastguard Worker<table> 426*5c90c05cSAndroid Build Coastguard Worker<tr> 427*5c90c05cSAndroid Build Coastguard Worker <th>Type</th> 428*5c90c05cSAndroid Build Coastguard Worker <th>Meaning</th> 429*5c90c05cSAndroid Build Coastguard Worker</tr> 430*5c90c05cSAndroid Build Coastguard Worker<tr> 431*5c90c05cSAndroid Build Coastguard Worker <td><code>'a'</code></td> 432*5c90c05cSAndroid Build Coastguard Worker <td> 433*5c90c05cSAndroid Build Coastguard Worker The abbreviated weekday name, e.g. "Sat". If the value does not contain a 434*5c90c05cSAndroid Build Coastguard Worker valid weekday, an exception of type <code>format_error</code> is thrown. 435*5c90c05cSAndroid Build Coastguard Worker </td> 436*5c90c05cSAndroid Build Coastguard Worker</tr> 437*5c90c05cSAndroid Build Coastguard Worker<tr> 438*5c90c05cSAndroid Build Coastguard Worker <td><code>'A'</code></td> 439*5c90c05cSAndroid Build Coastguard Worker <td> 440*5c90c05cSAndroid Build Coastguard Worker The full weekday name, e.g. "Saturday". If the value does not contain a 441*5c90c05cSAndroid Build Coastguard Worker valid weekday, an exception of type <code>format_error</code> is thrown. 442*5c90c05cSAndroid Build Coastguard Worker </td> 443*5c90c05cSAndroid Build Coastguard Worker</tr> 444*5c90c05cSAndroid Build Coastguard Worker<tr> 445*5c90c05cSAndroid Build Coastguard Worker <td><code>'b'</code></td> 446*5c90c05cSAndroid Build Coastguard Worker <td> 447*5c90c05cSAndroid Build Coastguard Worker The abbreviated month name, e.g. "Nov". If the value does not contain a 448*5c90c05cSAndroid Build Coastguard Worker valid month, an exception of type <code>format_error</code> is thrown. 449*5c90c05cSAndroid Build Coastguard Worker </td> 450*5c90c05cSAndroid Build Coastguard Worker</tr> 451*5c90c05cSAndroid Build Coastguard Worker<tr> 452*5c90c05cSAndroid Build Coastguard Worker <td><code>'B'</code></td> 453*5c90c05cSAndroid Build Coastguard Worker <td> 454*5c90c05cSAndroid Build Coastguard Worker The full month name, e.g. "November". If the value does not contain a valid 455*5c90c05cSAndroid Build Coastguard Worker month, an exception of type <code>format_error</code> is thrown. 456*5c90c05cSAndroid Build Coastguard Worker </td> 457*5c90c05cSAndroid Build Coastguard Worker</tr> 458*5c90c05cSAndroid Build Coastguard Worker<tr> 459*5c90c05cSAndroid Build Coastguard Worker <td><code>'c'</code></td> 460*5c90c05cSAndroid Build Coastguard Worker <td> 461*5c90c05cSAndroid Build Coastguard Worker The date and time representation, e.g. "Sat Nov 12 22:04:00 1955". The 462*5c90c05cSAndroid Build Coastguard Worker modified command <code>%Ec</code> produces the locale's alternate date and 463*5c90c05cSAndroid Build Coastguard Worker time representation. 464*5c90c05cSAndroid Build Coastguard Worker </td> 465*5c90c05cSAndroid Build Coastguard Worker</tr> 466*5c90c05cSAndroid Build Coastguard Worker<tr> 467*5c90c05cSAndroid Build Coastguard Worker <td><code>'C'</code></td> 468*5c90c05cSAndroid Build Coastguard Worker <td> 469*5c90c05cSAndroid Build Coastguard Worker The year divided by 100 using floored division, e.g. "19". If the result 470*5c90c05cSAndroid Build Coastguard Worker is a single decimal digit, it is prefixed with 0. The modified command 471*5c90c05cSAndroid Build Coastguard Worker <code>%EC</code> produces the locale's alternative representation of the 472*5c90c05cSAndroid Build Coastguard Worker century. 473*5c90c05cSAndroid Build Coastguard Worker </td> 474*5c90c05cSAndroid Build Coastguard Worker</tr> 475*5c90c05cSAndroid Build Coastguard Worker<tr> 476*5c90c05cSAndroid Build Coastguard Worker <td><code>'d'</code></td> 477*5c90c05cSAndroid Build Coastguard Worker <td> 478*5c90c05cSAndroid Build Coastguard Worker The day of month as a decimal number. If the result is a single decimal 479*5c90c05cSAndroid Build Coastguard Worker digit, it is prefixed with 0. The modified command <code>%Od</code> 480*5c90c05cSAndroid Build Coastguard Worker produces the locale's alternative representation. 481*5c90c05cSAndroid Build Coastguard Worker </td> 482*5c90c05cSAndroid Build Coastguard Worker</tr> 483*5c90c05cSAndroid Build Coastguard Worker<tr> 484*5c90c05cSAndroid Build Coastguard Worker <td><code>'D'</code></td> 485*5c90c05cSAndroid Build Coastguard Worker <td>Equivalent to <code>%m/%d/%y</code>, e.g. "11/12/55".</td> 486*5c90c05cSAndroid Build Coastguard Worker</tr> 487*5c90c05cSAndroid Build Coastguard Worker<tr> 488*5c90c05cSAndroid Build Coastguard Worker <td><code>'e'</code></td> 489*5c90c05cSAndroid Build Coastguard Worker <td> 490*5c90c05cSAndroid Build Coastguard Worker The day of month as a decimal number. If the result is a single decimal 491*5c90c05cSAndroid Build Coastguard Worker digit, it is prefixed with a space. The modified command <code>%Oe</code> 492*5c90c05cSAndroid Build Coastguard Worker produces the locale's alternative representation. 493*5c90c05cSAndroid Build Coastguard Worker </td> 494*5c90c05cSAndroid Build Coastguard Worker</tr> 495*5c90c05cSAndroid Build Coastguard Worker<tr> 496*5c90c05cSAndroid Build Coastguard Worker <td><code>'F'</code></td> 497*5c90c05cSAndroid Build Coastguard Worker <td>Equivalent to <code>%Y-%m-%d</code>, e.g. "1955-11-12".</td> 498*5c90c05cSAndroid Build Coastguard Worker</tr> 499*5c90c05cSAndroid Build Coastguard Worker<tr> 500*5c90c05cSAndroid Build Coastguard Worker <td><code>'g'</code></td> 501*5c90c05cSAndroid Build Coastguard Worker <td> 502*5c90c05cSAndroid Build Coastguard Worker The last two decimal digits of the ISO week-based year. If the result is a 503*5c90c05cSAndroid Build Coastguard Worker single digit it is prefixed by 0. 504*5c90c05cSAndroid Build Coastguard Worker </td> 505*5c90c05cSAndroid Build Coastguard Worker</tr> 506*5c90c05cSAndroid Build Coastguard Worker<tr> 507*5c90c05cSAndroid Build Coastguard Worker <td><code>'G'</code></td> 508*5c90c05cSAndroid Build Coastguard Worker <td> 509*5c90c05cSAndroid Build Coastguard Worker The ISO week-based year as a decimal number. If the result is less than 510*5c90c05cSAndroid Build Coastguard Worker four digits it is left-padded with 0 to four digits. 511*5c90c05cSAndroid Build Coastguard Worker </td> 512*5c90c05cSAndroid Build Coastguard Worker</tr> 513*5c90c05cSAndroid Build Coastguard Worker<tr> 514*5c90c05cSAndroid Build Coastguard Worker <td><code>'h'</code></td> 515*5c90c05cSAndroid Build Coastguard Worker <td>Equivalent to <code>%b</code>, e.g. "Nov".</td> 516*5c90c05cSAndroid Build Coastguard Worker</tr> 517*5c90c05cSAndroid Build Coastguard Worker<tr> 518*5c90c05cSAndroid Build Coastguard Worker <td><code>'H'</code></td> 519*5c90c05cSAndroid Build Coastguard Worker <td> 520*5c90c05cSAndroid Build Coastguard Worker The hour (24-hour clock) as a decimal number. If the result is a single 521*5c90c05cSAndroid Build Coastguard Worker digit, it is prefixed with 0. The modified command <code>%OH</code> 522*5c90c05cSAndroid Build Coastguard Worker produces the locale's alternative representation. 523*5c90c05cSAndroid Build Coastguard Worker </td> 524*5c90c05cSAndroid Build Coastguard Worker</tr> 525*5c90c05cSAndroid Build Coastguard Worker<tr> 526*5c90c05cSAndroid Build Coastguard Worker <td><code>'I'</code></td> 527*5c90c05cSAndroid Build Coastguard Worker <td> 528*5c90c05cSAndroid Build Coastguard Worker The hour (12-hour clock) as a decimal number. If the result is a single 529*5c90c05cSAndroid Build Coastguard Worker digit, it is prefixed with 0. The modified command <code>%OI</code> 530*5c90c05cSAndroid Build Coastguard Worker produces the locale's alternative representation. 531*5c90c05cSAndroid Build Coastguard Worker </td> 532*5c90c05cSAndroid Build Coastguard Worker</tr> 533*5c90c05cSAndroid Build Coastguard Worker<tr> 534*5c90c05cSAndroid Build Coastguard Worker <td><code>'j'</code></td> 535*5c90c05cSAndroid Build Coastguard Worker <td> 536*5c90c05cSAndroid Build Coastguard Worker If the type being formatted is a specialization of duration, the decimal 537*5c90c05cSAndroid Build Coastguard Worker number of days without padding. Otherwise, the day of the year as a decimal 538*5c90c05cSAndroid Build Coastguard Worker number. Jan 1 is 001. If the result is less than three digits, it is 539*5c90c05cSAndroid Build Coastguard Worker left-padded with 0 to three digits. 540*5c90c05cSAndroid Build Coastguard Worker </td> 541*5c90c05cSAndroid Build Coastguard Worker</tr> 542*5c90c05cSAndroid Build Coastguard Worker<tr> 543*5c90c05cSAndroid Build Coastguard Worker <td><code>'m'</code></td> 544*5c90c05cSAndroid Build Coastguard Worker <td> 545*5c90c05cSAndroid Build Coastguard Worker The month as a decimal number. Jan is 01. If the result is a single digit, 546*5c90c05cSAndroid Build Coastguard Worker it is prefixed with 0. The modified command <code>%Om</code> produces the 547*5c90c05cSAndroid Build Coastguard Worker locale's alternative representation. 548*5c90c05cSAndroid Build Coastguard Worker </td> 549*5c90c05cSAndroid Build Coastguard Worker</tr> 550*5c90c05cSAndroid Build Coastguard Worker<tr> 551*5c90c05cSAndroid Build Coastguard Worker <td><code>'M'</code></td> 552*5c90c05cSAndroid Build Coastguard Worker <td> 553*5c90c05cSAndroid Build Coastguard Worker The minute as a decimal number. If the result is a single digit, it 554*5c90c05cSAndroid Build Coastguard Worker is prefixed with 0. The modified command <code>%OM</code> produces the 555*5c90c05cSAndroid Build Coastguard Worker locale's alternative representation. 556*5c90c05cSAndroid Build Coastguard Worker </td> 557*5c90c05cSAndroid Build Coastguard Worker</tr> 558*5c90c05cSAndroid Build Coastguard Worker<tr> 559*5c90c05cSAndroid Build Coastguard Worker <td><code>'n'</code></td> 560*5c90c05cSAndroid Build Coastguard Worker <td>A new-line character.</td> 561*5c90c05cSAndroid Build Coastguard Worker</tr> 562*5c90c05cSAndroid Build Coastguard Worker<tr> 563*5c90c05cSAndroid Build Coastguard Worker <td><code>'p'</code></td> 564*5c90c05cSAndroid Build Coastguard Worker <td>The AM/PM designations associated with a 12-hour clock.</td> 565*5c90c05cSAndroid Build Coastguard Worker</tr> 566*5c90c05cSAndroid Build Coastguard Worker<tr> 567*5c90c05cSAndroid Build Coastguard Worker <td><code>'q'</code></td> 568*5c90c05cSAndroid Build Coastguard Worker <td>The duration's unit suffix.</td> 569*5c90c05cSAndroid Build Coastguard Worker</tr> 570*5c90c05cSAndroid Build Coastguard Worker<tr> 571*5c90c05cSAndroid Build Coastguard Worker <td><code>'Q'</code></td> 572*5c90c05cSAndroid Build Coastguard Worker <td> 573*5c90c05cSAndroid Build Coastguard Worker The duration's numeric value (as if extracted via <code>.count()</code>). 574*5c90c05cSAndroid Build Coastguard Worker </td> 575*5c90c05cSAndroid Build Coastguard Worker</tr> 576*5c90c05cSAndroid Build Coastguard Worker<tr> 577*5c90c05cSAndroid Build Coastguard Worker <td><code>'r'</code></td> 578*5c90c05cSAndroid Build Coastguard Worker <td>The 12-hour clock time, e.g. "10:04:00 PM".</td> 579*5c90c05cSAndroid Build Coastguard Worker</tr> 580*5c90c05cSAndroid Build Coastguard Worker<tr> 581*5c90c05cSAndroid Build Coastguard Worker <td><code>'R'</code></td> 582*5c90c05cSAndroid Build Coastguard Worker <td>Equivalent to <code>%H:%M</code>, e.g. "22:04".</td> 583*5c90c05cSAndroid Build Coastguard Worker</tr> 584*5c90c05cSAndroid Build Coastguard Worker<tr> 585*5c90c05cSAndroid Build Coastguard Worker <td><code>'S'</code></td> 586*5c90c05cSAndroid Build Coastguard Worker <td> 587*5c90c05cSAndroid Build Coastguard Worker Seconds as a decimal number. If the number of seconds is less than 10, the 588*5c90c05cSAndroid Build Coastguard Worker result is prefixed with 0. If the precision of the input cannot be exactly 589*5c90c05cSAndroid Build Coastguard Worker represented with seconds, then the format is a decimal floating-point number 590*5c90c05cSAndroid Build Coastguard Worker with a fixed format and a precision matching that of the precision of the 591*5c90c05cSAndroid Build Coastguard Worker input (or to a microseconds precision if the conversion to floating-point 592*5c90c05cSAndroid Build Coastguard Worker decimal seconds cannot be made within 18 fractional digits). The modified 593*5c90c05cSAndroid Build Coastguard Worker command <code>%OS</code> produces the locale's alternative representation. 594*5c90c05cSAndroid Build Coastguard Worker </td> 595*5c90c05cSAndroid Build Coastguard Worker</tr> 596*5c90c05cSAndroid Build Coastguard Worker<tr> 597*5c90c05cSAndroid Build Coastguard Worker <td><code>'t'</code></td> 598*5c90c05cSAndroid Build Coastguard Worker <td>A horizontal-tab character.</td> 599*5c90c05cSAndroid Build Coastguard Worker</tr> 600*5c90c05cSAndroid Build Coastguard Worker<tr> 601*5c90c05cSAndroid Build Coastguard Worker <td><code>'T'</code></td> 602*5c90c05cSAndroid Build Coastguard Worker <td>Equivalent to <code>%H:%M:%S</code>.</td> 603*5c90c05cSAndroid Build Coastguard Worker</tr> 604*5c90c05cSAndroid Build Coastguard Worker<tr> 605*5c90c05cSAndroid Build Coastguard Worker <td><code>'u'</code></td> 606*5c90c05cSAndroid Build Coastguard Worker <td> 607*5c90c05cSAndroid Build Coastguard Worker The ISO weekday as a decimal number (1-7), where Monday is 1. The modified 608*5c90c05cSAndroid Build Coastguard Worker command <code>%Ou</code> produces the locale's alternative representation. 609*5c90c05cSAndroid Build Coastguard Worker </td> 610*5c90c05cSAndroid Build Coastguard Worker</tr> 611*5c90c05cSAndroid Build Coastguard Worker<tr> 612*5c90c05cSAndroid Build Coastguard Worker <td><code>'U'</code></td> 613*5c90c05cSAndroid Build Coastguard Worker <td> 614*5c90c05cSAndroid Build Coastguard Worker The week number of the year as a decimal number. The first Sunday of the 615*5c90c05cSAndroid Build Coastguard Worker year is the first day of week 01. Days of the same year prior to that are 616*5c90c05cSAndroid Build Coastguard Worker in week 00. If the result is a single digit, it is prefixed with 0. 617*5c90c05cSAndroid Build Coastguard Worker The modified command <code>%OU</code> produces the locale's alternative 618*5c90c05cSAndroid Build Coastguard Worker representation. 619*5c90c05cSAndroid Build Coastguard Worker </td> 620*5c90c05cSAndroid Build Coastguard Worker</tr> 621*5c90c05cSAndroid Build Coastguard Worker<tr> 622*5c90c05cSAndroid Build Coastguard Worker <td><code>'V'</code></td> 623*5c90c05cSAndroid Build Coastguard Worker <td> 624*5c90c05cSAndroid Build Coastguard Worker The ISO week-based week number as a decimal number. If the result is a 625*5c90c05cSAndroid Build Coastguard Worker single digit, it is prefixed with 0. The modified command <code>%OV</code> 626*5c90c05cSAndroid Build Coastguard Worker produces the locale's alternative representation. 627*5c90c05cSAndroid Build Coastguard Worker </td> 628*5c90c05cSAndroid Build Coastguard Worker</tr> 629*5c90c05cSAndroid Build Coastguard Worker<tr> 630*5c90c05cSAndroid Build Coastguard Worker <td><code>'w'</code></td> 631*5c90c05cSAndroid Build Coastguard Worker <td> 632*5c90c05cSAndroid Build Coastguard Worker The weekday as a decimal number (0-6), where Sunday is 0. The modified 633*5c90c05cSAndroid Build Coastguard Worker command <code>%Ow</code> produces the locale's alternative representation. 634*5c90c05cSAndroid Build Coastguard Worker </td> 635*5c90c05cSAndroid Build Coastguard Worker</tr> 636*5c90c05cSAndroid Build Coastguard Worker<tr> 637*5c90c05cSAndroid Build Coastguard Worker <td><code>'W'</code></td> 638*5c90c05cSAndroid Build Coastguard Worker <td> 639*5c90c05cSAndroid Build Coastguard Worker The week number of the year as a decimal number. The first Monday of the 640*5c90c05cSAndroid Build Coastguard Worker year is the first day of week 01. Days of the same year prior to that are 641*5c90c05cSAndroid Build Coastguard Worker in week 00. If the result is a single digit, it is prefixed with 0. 642*5c90c05cSAndroid Build Coastguard Worker The modified command <code>%OW</code> produces the locale's alternative 643*5c90c05cSAndroid Build Coastguard Worker representation. 644*5c90c05cSAndroid Build Coastguard Worker </td> 645*5c90c05cSAndroid Build Coastguard Worker</tr> 646*5c90c05cSAndroid Build Coastguard Worker<tr> 647*5c90c05cSAndroid Build Coastguard Worker <td><code>'x'</code></td> 648*5c90c05cSAndroid Build Coastguard Worker <td> 649*5c90c05cSAndroid Build Coastguard Worker The date representation, e.g. "11/12/55". The modified command 650*5c90c05cSAndroid Build Coastguard Worker <code>%Ex</code> produces the locale's alternate date representation. 651*5c90c05cSAndroid Build Coastguard Worker </td> 652*5c90c05cSAndroid Build Coastguard Worker</tr> 653*5c90c05cSAndroid Build Coastguard Worker<tr> 654*5c90c05cSAndroid Build Coastguard Worker <td><code>'X'</code></td> 655*5c90c05cSAndroid Build Coastguard Worker <td> 656*5c90c05cSAndroid Build Coastguard Worker The time representation, e.g. "10:04:00". The modified command 657*5c90c05cSAndroid Build Coastguard Worker <code>%EX</code> produces the locale's alternate time representation. 658*5c90c05cSAndroid Build Coastguard Worker </td> 659*5c90c05cSAndroid Build Coastguard Worker</tr> 660*5c90c05cSAndroid Build Coastguard Worker<tr> 661*5c90c05cSAndroid Build Coastguard Worker <td><code>'y'</code></td> 662*5c90c05cSAndroid Build Coastguard Worker <td> 663*5c90c05cSAndroid Build Coastguard Worker The last two decimal digits of the year. If the result is a single digit 664*5c90c05cSAndroid Build Coastguard Worker it is prefixed by 0. The modified command <code>%Oy</code> produces the 665*5c90c05cSAndroid Build Coastguard Worker locale's alternative representation. The modified command <code>%Ey</code> 666*5c90c05cSAndroid Build Coastguard Worker produces the locale's alternative representation of offset from 667*5c90c05cSAndroid Build Coastguard Worker <code>%EC</code> (year only). 668*5c90c05cSAndroid Build Coastguard Worker </td> 669*5c90c05cSAndroid Build Coastguard Worker</tr> 670*5c90c05cSAndroid Build Coastguard Worker<tr> 671*5c90c05cSAndroid Build Coastguard Worker <td><code>'Y'</code></td> 672*5c90c05cSAndroid Build Coastguard Worker <td> 673*5c90c05cSAndroid Build Coastguard Worker The year as a decimal number. If the result is less than four digits it is 674*5c90c05cSAndroid Build Coastguard Worker left-padded with 0 to four digits. The modified command <code>%EY</code> 675*5c90c05cSAndroid Build Coastguard Worker produces the locale's alternative full year representation. 676*5c90c05cSAndroid Build Coastguard Worker </td> 677*5c90c05cSAndroid Build Coastguard Worker</tr> 678*5c90c05cSAndroid Build Coastguard Worker<tr> 679*5c90c05cSAndroid Build Coastguard Worker <td><code>'z'</code></td> 680*5c90c05cSAndroid Build Coastguard Worker <td> 681*5c90c05cSAndroid Build Coastguard Worker The offset from UTC in the ISO 8601:2004 format. For example -0430 refers 682*5c90c05cSAndroid Build Coastguard Worker to 4 hours 30 minutes behind UTC. If the offset is zero, +0000 is used. 683*5c90c05cSAndroid Build Coastguard Worker The modified commands <code>%Ez</code> and <code>%Oz</code> insert a 684*5c90c05cSAndroid Build Coastguard Worker <code>:</code> between the hours and minutes: -04:30. If the offset 685*5c90c05cSAndroid Build Coastguard Worker information is not available, an exception of type 686*5c90c05cSAndroid Build Coastguard Worker <code>format_error</code> is thrown. 687*5c90c05cSAndroid Build Coastguard Worker </td> 688*5c90c05cSAndroid Build Coastguard Worker</tr> 689*5c90c05cSAndroid Build Coastguard Worker<tr> 690*5c90c05cSAndroid Build Coastguard Worker <td><code>'Z'</code></td> 691*5c90c05cSAndroid Build Coastguard Worker <td> 692*5c90c05cSAndroid Build Coastguard Worker The time zone abbreviation. If the time zone abbreviation is not available, 693*5c90c05cSAndroid Build Coastguard Worker an exception of type <code>format_error</code> is thrown. 694*5c90c05cSAndroid Build Coastguard Worker </td> 695*5c90c05cSAndroid Build Coastguard Worker</tr> 696*5c90c05cSAndroid Build Coastguard Worker<tr> 697*5c90c05cSAndroid Build Coastguard Worker <td><code>'%'</code></td> 698*5c90c05cSAndroid Build Coastguard Worker <td>A % character.</td> 699*5c90c05cSAndroid Build Coastguard Worker</tr> 700*5c90c05cSAndroid Build Coastguard Worker</table> 701*5c90c05cSAndroid Build Coastguard Worker 702*5c90c05cSAndroid Build Coastguard WorkerSpecifiers that have a calendaric component such as `'d'` (the day of month) 703*5c90c05cSAndroid Build Coastguard Workerare valid only for `std::tm` and time points but not durations. 704*5c90c05cSAndroid Build Coastguard Worker 705*5c90c05cSAndroid Build Coastguard WorkerThe available padding modifiers (*padding_modifier*) are: 706*5c90c05cSAndroid Build Coastguard Worker 707*5c90c05cSAndroid Build Coastguard Worker| Type | Meaning | 708*5c90c05cSAndroid Build Coastguard Worker|-------|-----------------------------------------| 709*5c90c05cSAndroid Build Coastguard Worker| `'-'` | Pad a numeric result with spaces. | 710*5c90c05cSAndroid Build Coastguard Worker| `'_'` | Do not pad a numeric result string. | 711*5c90c05cSAndroid Build Coastguard Worker| `'0'` | Pad a numeric result string with zeros. | 712*5c90c05cSAndroid Build Coastguard Worker 713*5c90c05cSAndroid Build Coastguard WorkerThese modifiers are only supported for the `'H'`, `'I'`, `'M'`, `'S'`, `'U'`, 714*5c90c05cSAndroid Build Coastguard Worker`'V'`, `'W'`, `'m'`, `'j'`, `'Y'` presentation types. 715*5c90c05cSAndroid Build Coastguard Worker 716*5c90c05cSAndroid Build Coastguard Worker## Range Format Specifications 717*5c90c05cSAndroid Build Coastguard Worker 718*5c90c05cSAndroid Build Coastguard WorkerFormat specifications for range types have the following syntax: 719*5c90c05cSAndroid Build Coastguard Worker 720*5c90c05cSAndroid Build Coastguard Worker<pre><code class="language-json" 721*5c90c05cSAndroid Build Coastguard Worker>range_format_spec ::= ["n"][range_type][range_underlying_spec]</code> 722*5c90c05cSAndroid Build Coastguard Worker</pre> 723*5c90c05cSAndroid Build Coastguard Worker 724*5c90c05cSAndroid Build Coastguard WorkerThe `'n'` option formats the range without the opening and closing brackets. 725*5c90c05cSAndroid Build Coastguard Worker 726*5c90c05cSAndroid Build Coastguard WorkerThe available presentation types for `range_type` are: 727*5c90c05cSAndroid Build Coastguard Worker 728*5c90c05cSAndroid Build Coastguard Worker| Type | Meaning | 729*5c90c05cSAndroid Build Coastguard Worker|--------|------------------------------------------------------------| 730*5c90c05cSAndroid Build Coastguard Worker| none | Default format. | 731*5c90c05cSAndroid Build Coastguard Worker| `'s'` | String format. The range is formatted as a string. | 732*5c90c05cSAndroid Build Coastguard Worker| `'?s'` | Debug format. The range is formatted as an escaped string. | 733*5c90c05cSAndroid Build Coastguard Worker 734*5c90c05cSAndroid Build Coastguard WorkerIf `range_type` is `'s'` or `'?s'`, the range element type must be a character 735*5c90c05cSAndroid Build Coastguard Workertype. The `'n'` option and `range_underlying_spec` are mutually exclusive with 736*5c90c05cSAndroid Build Coastguard Worker`'s'` and `'?s'`. 737*5c90c05cSAndroid Build Coastguard Worker 738*5c90c05cSAndroid Build Coastguard WorkerThe `range_underlying_spec` is parsed based on the formatter of the range's 739*5c90c05cSAndroid Build Coastguard Workerelement type. 740*5c90c05cSAndroid Build Coastguard Worker 741*5c90c05cSAndroid Build Coastguard WorkerBy default, a range of characters or strings is printed escaped and quoted. 742*5c90c05cSAndroid Build Coastguard WorkerBut if any `range_underlying_spec` is provided (even if it is empty), then the 743*5c90c05cSAndroid Build Coastguard Workercharacters or strings are printed according to the provided specification. 744*5c90c05cSAndroid Build Coastguard Worker 745*5c90c05cSAndroid Build Coastguard WorkerExamples: 746*5c90c05cSAndroid Build Coastguard Worker 747*5c90c05cSAndroid Build Coastguard Worker```c++ 748*5c90c05cSAndroid Build Coastguard Workerfmt::print("{}", std::vector{10, 20, 30}); 749*5c90c05cSAndroid Build Coastguard Worker// Output: [10, 20, 30] 750*5c90c05cSAndroid Build Coastguard Workerfmt::print("{::#x}", std::vector{10, 20, 30}); 751*5c90c05cSAndroid Build Coastguard Worker// Output: [0xa, 0x14, 0x1e] 752*5c90c05cSAndroid Build Coastguard Workerfmt::print("{}", std::vector{'h', 'e', 'l', 'l', 'o'}); 753*5c90c05cSAndroid Build Coastguard Worker// Output: ['h', 'e', 'l', 'l', 'o'] 754*5c90c05cSAndroid Build Coastguard Workerfmt::print("{:n}", std::vector{'h', 'e', 'l', 'l', 'o'}); 755*5c90c05cSAndroid Build Coastguard Worker// Output: 'h', 'e', 'l', 'l', 'o' 756*5c90c05cSAndroid Build Coastguard Workerfmt::print("{:s}", std::vector{'h', 'e', 'l', 'l', 'o'}); 757*5c90c05cSAndroid Build Coastguard Worker// Output: "hello" 758*5c90c05cSAndroid Build Coastguard Workerfmt::print("{:?s}", std::vector{'h', 'e', 'l', 'l', 'o', '\n'}); 759*5c90c05cSAndroid Build Coastguard Worker// Output: "hello\n" 760*5c90c05cSAndroid Build Coastguard Workerfmt::print("{::}", std::vector{'h', 'e', 'l', 'l', 'o'}); 761*5c90c05cSAndroid Build Coastguard Worker// Output: [h, e, l, l, o] 762*5c90c05cSAndroid Build Coastguard Workerfmt::print("{::d}", std::vector{'h', 'e', 'l', 'l', 'o'}); 763*5c90c05cSAndroid Build Coastguard Worker// Output: [104, 101, 108, 108, 111] 764*5c90c05cSAndroid Build Coastguard Worker``` 765*5c90c05cSAndroid Build Coastguard Worker 766*5c90c05cSAndroid Build Coastguard Worker## Format Examples 767*5c90c05cSAndroid Build Coastguard Worker 768*5c90c05cSAndroid Build Coastguard WorkerThis section contains examples of the format syntax and comparison with 769*5c90c05cSAndroid Build Coastguard Workerthe printf formatting. 770*5c90c05cSAndroid Build Coastguard Worker 771*5c90c05cSAndroid Build Coastguard WorkerIn most of the cases the syntax is similar to the printf formatting, 772*5c90c05cSAndroid Build Coastguard Workerwith the addition of the `{}` and with `:` used instead of `%`. For 773*5c90c05cSAndroid Build Coastguard Workerexample, `"%03.2f"` can be translated to `"{:03.2f}"`. 774*5c90c05cSAndroid Build Coastguard Worker 775*5c90c05cSAndroid Build Coastguard WorkerThe new format syntax also supports new and different options, shown in 776*5c90c05cSAndroid Build Coastguard Workerthe following examples. 777*5c90c05cSAndroid Build Coastguard Worker 778*5c90c05cSAndroid Build Coastguard WorkerAccessing arguments by position: 779*5c90c05cSAndroid Build Coastguard Worker 780*5c90c05cSAndroid Build Coastguard Worker```c++ 781*5c90c05cSAndroid Build Coastguard Workerfmt::format("{0}, {1}, {2}", 'a', 'b', 'c'); 782*5c90c05cSAndroid Build Coastguard Worker// Result: "a, b, c" 783*5c90c05cSAndroid Build Coastguard Workerfmt::format("{}, {}, {}", 'a', 'b', 'c'); 784*5c90c05cSAndroid Build Coastguard Worker// Result: "a, b, c" 785*5c90c05cSAndroid Build Coastguard Workerfmt::format("{2}, {1}, {0}", 'a', 'b', 'c'); 786*5c90c05cSAndroid Build Coastguard Worker// Result: "c, b, a" 787*5c90c05cSAndroid Build Coastguard Workerfmt::format("{0}{1}{0}", "abra", "cad"); // arguments' indices can be repeated 788*5c90c05cSAndroid Build Coastguard Worker// Result: "abracadabra" 789*5c90c05cSAndroid Build Coastguard Worker``` 790*5c90c05cSAndroid Build Coastguard Worker 791*5c90c05cSAndroid Build Coastguard WorkerAligning the text and specifying a width: 792*5c90c05cSAndroid Build Coastguard Worker 793*5c90c05cSAndroid Build Coastguard Worker```c++ 794*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:<30}", "left aligned"); 795*5c90c05cSAndroid Build Coastguard Worker// Result: "left aligned " 796*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:>30}", "right aligned"); 797*5c90c05cSAndroid Build Coastguard Worker// Result: " right aligned" 798*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:^30}", "centered"); 799*5c90c05cSAndroid Build Coastguard Worker// Result: " centered " 800*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:*^30}", "centered"); // use '*' as a fill char 801*5c90c05cSAndroid Build Coastguard Worker// Result: "***********centered***********" 802*5c90c05cSAndroid Build Coastguard Worker``` 803*5c90c05cSAndroid Build Coastguard Worker 804*5c90c05cSAndroid Build Coastguard WorkerDynamic width: 805*5c90c05cSAndroid Build Coastguard Worker 806*5c90c05cSAndroid Build Coastguard Worker```c++ 807*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:<{}}", "left aligned", 30); 808*5c90c05cSAndroid Build Coastguard Worker// Result: "left aligned " 809*5c90c05cSAndroid Build Coastguard Worker``` 810*5c90c05cSAndroid Build Coastguard Worker 811*5c90c05cSAndroid Build Coastguard WorkerDynamic precision: 812*5c90c05cSAndroid Build Coastguard Worker 813*5c90c05cSAndroid Build Coastguard Worker```c++ 814*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:.{}f}", 3.14, 1); 815*5c90c05cSAndroid Build Coastguard Worker// Result: "3.1" 816*5c90c05cSAndroid Build Coastguard Worker``` 817*5c90c05cSAndroid Build Coastguard Worker 818*5c90c05cSAndroid Build Coastguard WorkerReplacing `%+f`, `%-f`, and `% f` and specifying a sign: 819*5c90c05cSAndroid Build Coastguard Worker 820*5c90c05cSAndroid Build Coastguard Worker```c++ 821*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:+f}; {:+f}", 3.14, -3.14); // show it always 822*5c90c05cSAndroid Build Coastguard Worker// Result: "+3.140000; -3.140000" 823*5c90c05cSAndroid Build Coastguard Workerfmt::format("{: f}; {: f}", 3.14, -3.14); // show a space for positive numbers 824*5c90c05cSAndroid Build Coastguard Worker// Result: " 3.140000; -3.140000" 825*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:-f}; {:-f}", 3.14, -3.14); // show only the minus -- same as '{:f}; {:f}' 826*5c90c05cSAndroid Build Coastguard Worker// Result: "3.140000; -3.140000" 827*5c90c05cSAndroid Build Coastguard Worker``` 828*5c90c05cSAndroid Build Coastguard Worker 829*5c90c05cSAndroid Build Coastguard WorkerReplacing `%x` and `%o` and converting the value to different bases: 830*5c90c05cSAndroid Build Coastguard Worker 831*5c90c05cSAndroid Build Coastguard Worker```c++ 832*5c90c05cSAndroid Build Coastguard Workerfmt::format("int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42); 833*5c90c05cSAndroid Build Coastguard Worker// Result: "int: 42; hex: 2a; oct: 52; bin: 101010" 834*5c90c05cSAndroid Build Coastguard Worker// with 0x or 0 or 0b as prefix: 835*5c90c05cSAndroid Build Coastguard Workerfmt::format("int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}", 42); 836*5c90c05cSAndroid Build Coastguard Worker// Result: "int: 42; hex: 0x2a; oct: 052; bin: 0b101010" 837*5c90c05cSAndroid Build Coastguard Worker``` 838*5c90c05cSAndroid Build Coastguard Worker 839*5c90c05cSAndroid Build Coastguard WorkerPadded hex byte with prefix and always prints both hex characters: 840*5c90c05cSAndroid Build Coastguard Worker 841*5c90c05cSAndroid Build Coastguard Worker```c++ 842*5c90c05cSAndroid Build Coastguard Workerfmt::format("{:#04x}", 0); 843*5c90c05cSAndroid Build Coastguard Worker// Result: "0x00" 844*5c90c05cSAndroid Build Coastguard Worker``` 845*5c90c05cSAndroid Build Coastguard Worker 846*5c90c05cSAndroid Build Coastguard WorkerBox drawing using Unicode fill: 847*5c90c05cSAndroid Build Coastguard Worker 848*5c90c05cSAndroid Build Coastguard Worker```c++ 849*5c90c05cSAndroid Build Coastguard Workerfmt::print( 850*5c90c05cSAndroid Build Coastguard Worker "┌{0:─^{2}}┐\n" 851*5c90c05cSAndroid Build Coastguard Worker "│{1: ^{2}}│\n" 852*5c90c05cSAndroid Build Coastguard Worker "└{0:─^{2}}┘\n", "", "Hello, world!", 20); 853*5c90c05cSAndroid Build Coastguard Worker``` 854*5c90c05cSAndroid Build Coastguard Worker 855*5c90c05cSAndroid Build Coastguard Workerprints: 856*5c90c05cSAndroid Build Coastguard Worker 857*5c90c05cSAndroid Build Coastguard Worker``` 858*5c90c05cSAndroid Build Coastguard Worker┌────────────────────┐ 859*5c90c05cSAndroid Build Coastguard Worker│ Hello, world! │ 860*5c90c05cSAndroid Build Coastguard Worker└────────────────────┘ 861*5c90c05cSAndroid Build Coastguard Worker``` 862*5c90c05cSAndroid Build Coastguard Worker 863*5c90c05cSAndroid Build Coastguard WorkerUsing type-specific formatting: 864*5c90c05cSAndroid Build Coastguard Worker 865*5c90c05cSAndroid Build Coastguard Worker```c++ 866*5c90c05cSAndroid Build Coastguard Worker#include <fmt/chrono.h> 867*5c90c05cSAndroid Build Coastguard Worker 868*5c90c05cSAndroid Build Coastguard Workerauto t = tm(); 869*5c90c05cSAndroid Build Coastguard Workert.tm_year = 2010 - 1900; 870*5c90c05cSAndroid Build Coastguard Workert.tm_mon = 7; 871*5c90c05cSAndroid Build Coastguard Workert.tm_mday = 4; 872*5c90c05cSAndroid Build Coastguard Workert.tm_hour = 12; 873*5c90c05cSAndroid Build Coastguard Workert.tm_min = 15; 874*5c90c05cSAndroid Build Coastguard Workert.tm_sec = 58; 875*5c90c05cSAndroid Build Coastguard Workerfmt::print("{:%Y-%m-%d %H:%M:%S}", t); 876*5c90c05cSAndroid Build Coastguard Worker// Prints: 2010-08-04 12:15:58 877*5c90c05cSAndroid Build Coastguard Worker``` 878*5c90c05cSAndroid Build Coastguard Worker 879*5c90c05cSAndroid Build Coastguard WorkerUsing the comma as a thousands separator: 880*5c90c05cSAndroid Build Coastguard Worker 881*5c90c05cSAndroid Build Coastguard Worker```c++ 882*5c90c05cSAndroid Build Coastguard Worker#include <fmt/format.h> 883*5c90c05cSAndroid Build Coastguard Worker 884*5c90c05cSAndroid Build Coastguard Workerauto s = fmt::format(std::locale("en_US.UTF-8"), "{:L}", 1234567890); 885*5c90c05cSAndroid Build Coastguard Worker// s == "1,234,567,890" 886*5c90c05cSAndroid Build Coastguard Worker``` 887