2 USING: help.syntax help.markup kernel prettyprint sequences strings ;
7 { $values { "format-string" string } }
9 "Writes the arguments (specified on the stack) formatted according to the format string."
11 "Several format specifications exist for handling arguments of different types, and "
12 "specifying attributes for the result string, including such things as maximum width, "
13 "padding, and decimals."
16 { { $snippet "%%" } "Single %" "" }
17 { { $snippet "%P.Ds" } "String format" "string" }
18 { { $snippet "%P.DS" } "String format uppercase" "string" }
19 { { $snippet "%P.Du" } "Unparsed format" "object" }
20 { { $snippet "%c" } "Character format" "char" }
21 { { $snippet "%C" } "Character format uppercase" "char" }
22 { { $snippet "%+Pd" } "Integer format (base 10)" "integer" }
23 { { $snippet "%+Po" } "Octal format (base 8)" "integer" }
24 { { $snippet "%+Pb" } "Binary format (base 2)" "integer" }
25 { { $snippet "%+P.De" } "Scientific notation" "real" }
26 { { $snippet "%+P.DE" } "Scientific notation" "real" }
27 { { $snippet "%+P.Df" } "Fixed format" "real" }
28 { { $snippet "%+Px" } "Hexadecimal (base 16)" "integer" }
29 { { $snippet "%+PX" } "Hexadecimal (base 16) uppercase" "integer" }
30 { { $snippet "%[%?, %]" } "Sequence format" "sequence" }
31 { { $snippet "%[%?: %? %]" } "Assocs format" "assocs" }
34 "A plus sign (" { $snippet "+" } ") is used to optionally specify that the number should be "
35 "formatted with a " { $snippet "+" } " preceeding it if positive."
37 "Padding (" { $snippet "P" } ") is used to optionally specify the minimum width of the result "
38 "string, the padding character, and the alignment. By default, the padding "
39 "character defaults to a space and the alignment defaults to right-aligned. "
43 { { $snippet "%5s" } " formats a string padding with spaces up to 5 characters wide." }
44 { { $snippet "%03d" } " formats an integer padding with zeros up to 3 characters wide." }
45 { { $snippet "%'#10f" } " formats a float padding with " { $snippet "#" } " up to 10 characters wide." }
46 { { $snippet "%-10d" } " formats an integer to 10 characters wide and left-aligns." }
49 "Digits (" { $snippet "D" } ") is used to optionally specify the maximum digits in the result "
50 "string. For example:"
53 { { $snippet "%.3s" } " formats a string to truncate at 3 characters (from the left)." }
54 { { $snippet "%.10f" } " formats a float to pad-tail with zeros up to 10 digits beyond the decimal point." }
55 { { $snippet "%.5E" } " formats a float into scientific notation with zeros up to 5 digits beyond the decimal point, but before the exponent." }
65 "0xff \"%04X\" printf"
73 "1.23456789 \"%.3f\" printf"
85 "{ 1 2 3 } \"%[%d, %]\" printf"
89 "H{ { 1 2 } { 3 4 } } \"%[%d: %d %]\" printf"
92 "USING: calendar formatting ;"
93 "3 years \"%u\" printf"
94 "T{ duration { year 3 } }" }
98 { $values { "format-string" string } { "result" string } }
99 { $description "Returns the arguments (specified on the stack) formatted according to the format string as a result string." }
100 { $see-also printf } ;
103 { $values { "format-string" string } }
105 "Writes the timestamp (specified on the stack) formatted according to the format string."
107 "Different attributes of the timestamp can be retrieved using format specifications."
110 { { $snippet "%a" } "Abbreviated weekday name." }
111 { { $snippet "%A" } "Full weekday name." }
112 { { $snippet "%b" } "Abbreviated month name." }
113 { { $snippet "%B" } "Full month name." }
114 { { $snippet "%c" } "Date and time representation." }
115 { { $snippet "%d" } "Day of the month as a decimal number [01,31]." }
116 { { $snippet "%H" } "Hour (24-hour clock) as a decimal number [00,23]." }
117 { { $snippet "%I" } "Hour (12-hour clock) as a decimal number [01,12]." }
118 { { $snippet "%j" } "Day of the year as a decimal number [001,366]." }
119 { { $snippet "%m" } "Month as a decimal number [01,12]." }
120 { { $snippet "%M" } "Minute as a decimal number [00,59]." }
121 { { $snippet "%p" } "Either AM or PM." }
122 { { $snippet "%S" } "Second as a decimal number [00,59]." }
123 { { $snippet "%U" } "Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]." }
124 { { $snippet "%w" } "Weekday as a decimal number [0(Sunday),6]." }
125 { { $snippet "%W" } "Week number of the year (Monday as the first day of the week) as a decimal number [00,53]." }
126 { { $snippet "%x" } "Date representation." }
127 { { $snippet "%X" } "Time representation." }
128 { { $snippet "%y" } "Year without century as a decimal number [00,99]." }
129 { { $snippet "%Y" } "Year with century as a decimal number." }
130 { { $snippet "%Z" } "Time zone name (no characters if no time zone exists)." }
131 { { $snippet "%%" } "A literal '%' character." }
136 "USING: calendar formatting io ;"
137 "now \"%c\" strftime print"
138 "Mon Dec 15 14:40:43 2008" }
141 ARTICLE: "formatting" "Formatted printing"
142 "The " { $vocab-link "formatting" } " vocabulary is used for english formatted printing."