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.\n"
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.\n"
15 { "%%" "Single %" "" }
16 { "%P.Ds" "String format" "string" }
17 { "%P.DS" "String format uppercase" "string" }
18 { "%c" "Character format" "char" }
19 { "%C" "Character format uppercase" "char" }
20 { "%+Pd" "Integer format" "fixnum" }
21 { "%+P.De" "Scientific notation" "fixnum, float" }
22 { "%+P.DE" "Scientific notation" "fixnum, float" }
23 { "%+P.Df" "Fixed format" "fixnum, float" }
24 { "%+Px" "Hexadecimal" "hex" }
25 { "%+PX" "Hexadecimal uppercase" "hex" }
26 { "%[%?, %]" "Sequence format" "sequence" }
27 { "%[%?: %? %]" "Assocs format" "assocs" }
30 "A plus sign ('+') is used to optionally specify that the number should be "
31 "formatted with a '+' preceeding it if positive.\n"
33 "Padding ('P') is used to optionally specify the minimum width of the result "
34 "string, the padding character, and the alignment. By default, the padding "
35 "character defaults to a space and the alignment defaults to right-aligned. "
38 "\"%5s\" formats a string padding with spaces up to 5 characters wide."
39 "\"%08d\" formats an integer padding with zeros up to 3 characters wide."
40 "\"%'#5f\" formats a float padding with '#' up to 3 characters wide."
41 "\"%-10d\" formats an integer to 10 characters wide and left-aligns."
44 "Digits ('D') is used to optionally specify the maximum digits in the result "
45 "string. For example:\n"
47 "\"%.3s\" formats a string to truncate at 3 characters (from the left)."
48 "\"%.10f\" formats a float to pad-tail with zeros up to 10 digits beyond the decimal point."
49 "\"%.5E\" formats a float into scientific notation with zeros up to 5 digits beyond the decimal point, but before the exponent."
59 "HEX: ff \"%04X\" printf"
63 "1.23456789 \"%.3f\" printf"
67 "1234567890 \"%.5e\" printf"
79 "{ 1 2 3 } \"%[%d, %]\" printf"
83 "H{ { 1 2 } { 3 4 } } \"%[%d: %d %]\" printf"
88 { $values { "format-string" string } { "result" string } }
89 { $description "Returns the arguments (specified on the stack) formatted according to the format string as a result string." }
90 { $see-also printf } ;
93 { $values { "format-string" string } }
95 "Writes the timestamp (specified on the stack) formatted according to the format string.\n"
97 "Different attributes of the timestamp can be retrieved using format specifications.\n"
99 { "%a" "Abbreviated weekday name." }
100 { "%A" "Full weekday name." }
101 { "%b" "Abbreviated month name." }
102 { "%B" "Full month name." }
103 { "%c" "Date and time representation." }
104 { "%d" "Day of the month as a decimal number [01,31]." }
105 { "%H" "Hour (24-hour clock) as a decimal number [00,23]." }
106 { "%I" "Hour (12-hour clock) as a decimal number [01,12]." }
107 { "%j" "Day of the year as a decimal number [001,366]." }
108 { "%m" "Month as a decimal number [01,12]." }
109 { "%M" "Minute as a decimal number [00,59]." }
110 { "%p" "Either AM or PM." }
111 { "%S" "Second as a decimal number [00,59]." }
112 { "%U" "Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]." }
113 { "%w" "Weekday as a decimal number [0(Sunday),6]." }
114 { "%W" "Week number of the year (Monday as the first day of the week) as a decimal number [00,53]." }
115 { "%x" "Date representation." }
116 { "%X" "Time representation." }
117 { "%y" "Year without century as a decimal number [00,99]." }
118 { "%Y" "Year with century as a decimal number." }
119 { "%Z" "Time zone name (no characters if no time zone exists)." }
120 { "%%" "A literal '%' character." }
125 "USING: calendar formatting io ;"
126 "now \"%c\" strftime print"
127 "Mon Dec 15 14:40:43 2008" }
130 ARTICLE: "formatting" "Formatted printing"
131 "The " { $vocab-link "formatting" } " vocabulary is used for formatted printing."