]>
Commit | Line | Data |
---|---|---|
5b2abdfb A |
1 | .\" Copyright (c) 1989, 1991, 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" the American National Standards Committee X3, on Information | |
6 | .\" Processing Systems. | |
7 | .\" | |
8 | .\" Redistribution and use in source and binary forms, with or without | |
9 | .\" modification, are permitted provided that the following conditions | |
10 | .\" are met: | |
11 | .\" 1. Redistributions of source code must retain the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer. | |
13 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
14 | .\" notice, this list of conditions and the following disclaimer in the | |
15 | .\" documentation and/or other materials provided with the distribution. | |
16 | .\" 3. All advertising materials mentioning features or use of this software | |
17 | .\" must display the following acknowledgement: | |
18 | .\" This product includes software developed by the University of | |
19 | .\" California, Berkeley and its contributors. | |
20 | .\" 4. Neither the name of the University nor the names of its contributors | |
21 | .\" may be used to endorse or promote products derived from this software | |
22 | .\" without specific prior written permission. | |
23 | .\" | |
24 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
25 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
26 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
27 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
28 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
29 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
30 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
31 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
32 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
33 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
34 | .\" SUCH DAMAGE. | |
35 | .\" | |
36 | .\" @(#)strftime.3 8.1 (Berkeley) 6/4/93 | |
37 | .\" $FreeBSD: src/lib/libc/stdtime/strftime.3,v 1.18.2.7 2001/12/14 18:33:59 ru Exp $ | |
38 | .\" | |
39 | .Dd October 4, 1997 | |
40 | .Dt STRFTIME 3 | |
41 | .Os | |
42 | .Sh NAME | |
43 | .Nm strftime | |
44 | .Nd format date and time | |
45 | .Sh LIBRARY | |
46 | .Lb libc | |
47 | .Sh SYNOPSIS | |
48 | .In time.h | |
49 | .Ft size_t | |
50 | .Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr" | |
51 | .Sh DESCRIPTION | |
52 | The | |
53 | .Fn strftime | |
54 | function formats the information from | |
55 | .Fa timeptr | |
56 | into the buffer | |
57 | .Fa buf | |
58 | according to the string pointed to by | |
59 | .Fa format . | |
60 | .Pp | |
61 | The | |
62 | .Fa format | |
63 | string consists of zero or more conversion specifications and | |
64 | ordinary characters. | |
65 | All ordinary characters are copied directly into the buffer. | |
66 | A conversion specification consists of a percent sign | |
67 | .Dq Ql % | |
68 | and one other character. | |
69 | .Pp | |
70 | No more than | |
71 | .Fa maxsize | |
72 | characters will be placed into the array. | |
73 | If the total number of resulting characters, including the terminating | |
74 | NUL character, is not more than | |
75 | .Fa maxsize , | |
76 | .Fn strftime | |
77 | returns the number of characters in the array, not counting the | |
78 | terminating NUL. | |
79 | Otherwise, zero is returned and the buffer contents is indeterminate. | |
80 | .Pp | |
81 | The conversion specifications are copied to the buffer after expansion | |
82 | as follows:- | |
83 | .Bl -tag -width "xxxx" | |
84 | .It Cm \&%A | |
85 | is replaced by national representation of the full weekday name. | |
86 | .It Cm %a | |
87 | is replaced by national representation of | |
88 | the abbreviated weekday name, where the abbreviation | |
89 | is the first three characters. | |
90 | .It Cm \&%B | |
91 | is replaced by national representation of the full month name. | |
92 | .It Cm %b | |
93 | is replaced by national representation of | |
94 | the abbreviated month name, where the abbreviation is | |
95 | the first three characters. | |
96 | .It Cm \&%C | |
97 | is replaced by (year / 100) as decimal number; single | |
98 | digits are preceded by a zero. | |
99 | .It Cm %c | |
100 | is replaced by national representation of time and date. | |
101 | The format is similar to that produced by | |
102 | .Xr ctime 3 | |
103 | and is | |
104 | equivalent to "%a %Ef %T %Y". | |
105 | It also implies the | |
106 | "3+1+6+1+8+1+4" format of output. | |
107 | .It Cm \&%D | |
108 | is equivalent to | |
109 | .Dq Li %m/%d/%y . | |
110 | .It Cm %d | |
111 | is replaced by the day of the month as a decimal number (01-31). | |
112 | .It Cm \&%E* Cm \&%O* | |
113 | POSIX locale extensions. | |
114 | The sequences | |
115 | %Ec %EC %Ex %EX %Ey %EY | |
116 | %Od %Oe %OH %OI %Om %OM | |
117 | %OS %Ou %OU %OV %Ow %OW %Oy | |
118 | are supposed to provide alternate | |
119 | representations. | |
120 | .Pp | |
121 | Additionly %Ef implemented to represent short month name / day | |
122 | order of the date, %EF to represent long month name / day | |
123 | order | |
124 | and %OB to represent alternative months names | |
125 | (used standalone, without day mentioned). | |
126 | .It Cm %e | |
127 | is replaced by the day of month as a decimal number (1-31); single | |
128 | digits are preceded by a blank. | |
129 | .It Cm \&%G | |
130 | is replaced by a year as a decimal number with century. | |
131 | This year is the one that contains the greater part of | |
132 | the week (Monday as the first day of the week). | |
133 | .It Cm %g | |
134 | is replaced by the same year as in | |
135 | .Dq Li %G , | |
136 | but as a decimal number without century (00-99). | |
137 | .It Cm \&%H | |
138 | is replaced by the hour (24-hour clock) as a decimal number (00-23). | |
139 | .It Cm %h | |
140 | the same as %b. | |
141 | .It Cm \&%I | |
142 | is replaced by the hour (12-hour clock) as a decimal number (01-12). | |
143 | .It Cm %j | |
144 | is replaced by the day of the year as a decimal number (001-366). | |
145 | .It Cm %k | |
146 | is replaced by the hour (24-hour clock) as a decimal number (0-23); | |
147 | single digits are preceded by a blank. | |
148 | .It Cm %l | |
149 | is replaced by the hour (12-hour clock) as a decimal number (1-12); | |
150 | single digits are preceded by a blank. | |
151 | .It Cm \&%M | |
152 | is replaced by the minute as a decimal number (00-59). | |
153 | .It Cm %m | |
154 | is replaced by the month as a decimal number (01-12). | |
155 | .It Cm %n | |
156 | is replaced by a newline. | |
157 | .It Cm \&%O* | |
158 | the same as %E*. | |
159 | .It Cm %p | |
160 | is replaced by national representation of either | |
161 | "ante meridiem" | |
162 | or | |
163 | "post meridiem" | |
164 | as appropriate. | |
165 | .It Cm \&%R | |
166 | is equivalent to | |
167 | .Dq Li %H:%M . | |
168 | .It Cm %r | |
169 | is equivalent to | |
170 | .Dq Li %I:%M:%S %p . | |
171 | .It Cm \&%S | |
172 | is replaced by the second as a decimal number (00-60). | |
173 | .It Cm %s | |
174 | is replaced by the number of seconds since the Epoch, UTC (see | |
175 | .Xr mktime 3 ) . | |
176 | .It Cm \&%T | |
177 | is equivalent to | |
178 | .Dq Li %H:%M:%S . | |
179 | .It Cm %t | |
180 | is replaced by a tab. | |
181 | .It Cm \&%U | |
182 | is replaced by the week number of the year (Sunday as the first day of | |
183 | the week) as a decimal number (00-53). | |
184 | .It Cm %u | |
185 | is replaced by the weekday (Monday as the first day of the week) | |
186 | as a decimal number (1-7). | |
187 | .It Cm \&%V | |
188 | is replaced by the week number of the year (Monday as the first day of | |
189 | the week) as a decimal number (01-53). If the week containing January | |
190 | 1 has four or more days in the new year, then it is week 1; otherwise | |
191 | it is the last week of the previous year, and the next week is week 1. | |
192 | .It Cm %v | |
193 | is equivalent to | |
194 | .Dq Li %e-%b-%Y . | |
195 | .It Cm \&%W | |
196 | is replaced by the week number of the year (Monday as the first day of | |
197 | the week) as a decimal number (00-53). | |
198 | .It Cm %w | |
199 | is replaced by the weekday (Sunday as the first day of the week) | |
200 | as a decimal number (0-6). | |
201 | .It Cm \&%X | |
202 | is replaced by national representation of the time. | |
203 | .It Cm %x | |
204 | is replaced by national representation of the date. | |
205 | .It Cm \&%Y | |
206 | is replaced by the year with century as a decimal number. | |
207 | .It Cm %y | |
208 | is replaced by the year without century as a decimal number (00-99). | |
209 | .It Cm \&%Z | |
210 | is replaced by the time zone name. | |
211 | .It Cm \&%z | |
212 | is replaced by the time zone offset from UTC; a leading plus sign stands for | |
213 | east of UTC, a minus sign for west of UTC, hours and minutes follow | |
214 | with two digits each and no delimiter between them (common form for | |
215 | RFC 822 date headers). | |
216 | .It Cm %+ | |
217 | is replaced by national representation of the date and time | |
218 | (the format is similar to that produced by | |
219 | .Xr date 1 ) . | |
220 | .It Cm %% | |
221 | is replaced by | |
222 | .Ql % . | |
223 | .El | |
224 | .Sh SEE ALSO | |
225 | .Xr date 1 , | |
226 | .Xr printf 1 , | |
227 | .Xr ctime 3 , | |
228 | .Xr printf 3 , | |
229 | .Xr strptime 3 | |
230 | .Sh STANDARDS | |
231 | The | |
232 | .Fn strftime | |
233 | function | |
234 | conforms to | |
235 | .St -isoC | |
236 | with a lot of extensions including | |
237 | .Ql %C , | |
238 | .Ql \&%D , | |
239 | .Ql %E* , | |
240 | .Ql %e , | |
241 | .Ql %G , | |
242 | .Ql %g , | |
243 | .Ql %h , | |
244 | .Ql %k , | |
245 | .Ql %l , | |
246 | .Ql %n , | |
247 | .Ql %O* , | |
248 | .Ql \&%R , | |
249 | .Ql %r , | |
250 | .Ql %s , | |
251 | .Ql \&%T , | |
252 | .Ql %t , | |
253 | .Ql %u , | |
254 | .Ql \&%V , | |
255 | .Ql %z , | |
256 | .Ql %+ . | |
257 | .Pp | |
258 | The peculiar week number and year in the replacements of | |
259 | .Ql %G , | |
260 | .Ql %g | |
261 | and | |
262 | .Ql \&%V | |
263 | are defined in ISO 8601: 1988. | |
264 | .Sh BUGS | |
265 | There is no conversion specification for the phase of the moon. |