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" }
28 "A plus sign ('+') is used to optionally specify that the number should be "
29 "formatted with a '+' preceeding it if positive.\n"
31 "Padding ('P') is used to optionally specify the minimum width of the result "
32 "string, the padding character, and the alignment. By default, the padding "
33 "character defaults to a space and the alignment defaults to right-aligned. "
36 "\"%5s\" formats a string padding with spaces up to 5 characters wide."
37 "\"%08d\" formats an integer padding with zeros up to 3 characters wide."
38 "\"%'#5f\" formats a float padding with '#' up to 3 characters wide."
39 "\"%-10d\" formats an integer to 10 characters wide and left-aligns."
42 "Digits ('D') is used to optionally specify the maximum digits in the result "
43 "string. For example:\n"
45 "\"%.3s\" formats a string to truncate at 3 characters (from the left)."
46 "\"%.10f\" formats a float to pad-right with zeros up to 10 digits beyond the decimal point."
47 "\"%.5E\" formats a float into scientific notation with zeros up to 5 digits beyond the decimal point, but before the exponent."
57 "HEX: ff \"%04X\" printf"
61 "1.23456789 \"%.3f\" printf"
65 "1234567890 \"%.5e\" printf"
78 { $values { "format-string" string } { "result" string } }
79 { $description "Returns the arguments (specified on the stack) formatted according to the format string as a result string." }
80 { $see-also printf } ;
83 { $values { "format-string" string } }
85 "Writes the timestamp (specified on the stack) formatted according to the format string.\n"
87 "Different attributes of the timestamp can be retrieved using format specifications.\n"
89 { "%a" "Abbreviated weekday name." }
90 { "%A" "Full weekday name." }
91 { "%b" "Abbreviated month name." }
92 { "%B" "Full month name." }
93 { "%c" "Date and time representation." }
94 { "%d" "Day of the month as a decimal number [01,31]." }
95 { "%H" "Hour (24-hour clock) as a decimal number [00,23]." }
96 { "%I" "Hour (12-hour clock) as a decimal number [01,12]." }
97 { "%j" "Day of the year as a decimal number [001,366]." }
98 { "%m" "Month as a decimal number [01,12]." }
99 { "%M" "Minute as a decimal number [00,59]." }
100 { "%p" "Either AM or PM." }
101 { "%S" "Second as a decimal number [00,59]." }
102 { "%U" "Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]." }
103 { "%w" "Weekday as a decimal number [0(Sunday),6]." }
104 { "%W" "Week number of the year (Monday as the first day of the week) as a decimal number [00,53]." }
105 { "%x" "Date representation." }
106 { "%X" "Time representation." }
107 { "%y" "Year without century as a decimal number [00,99]." }
108 { "%Y" "Year with century as a decimal number." }
109 { "%Z" "Time zone name (no characters if no time zone exists)." }
110 { "%%" "A literal '%' character." }
115 "USING: calendar formatting io ;"
116 "now \"%c\" strftime print"
117 "Mon Dec 15 14:40:43 2008" }
120 ARTICLE: "formatting" "Formatted printing"
121 "The " { $vocab-link "formatting" } " vocabulary is used for formatted printing.\n"
122 { $subsection printf }
123 { $subsection sprintf }
124 { $subsection strftime }