]> git.saurik.com Git - apple/libc.git/blame - stdtime/FreeBSD/strftime.3
Libc-391.tar.gz
[apple/libc.git] / stdtime / FreeBSD / strftime.3
CommitLineData
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
3d9156a7 37.\" $FreeBSD: src/lib/libc/stdtime/strftime.3,v 1.34 2004/07/02 23:52:12 ru Exp $
5b2abdfb 38.\"
9385eb3d 39.Dd January 4, 2003
5b2abdfb
A
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
9385eb3d
A
50.Fo strftime
51.Fa "char * restrict buf"
52.Fa "size_t maxsize"
53.Fa "const char * restrict format"
54.Fa "const struct tm * restrict timeptr"
55.Fc
5b2abdfb
A
56.Sh DESCRIPTION
57The
58.Fn strftime
59function formats the information from
60.Fa timeptr
61into the buffer
62.Fa buf
63according to the string pointed to by
64.Fa format .
65.Pp
66The
67.Fa format
68string consists of zero or more conversion specifications and
69ordinary characters.
70All ordinary characters are copied directly into the buffer.
71A conversion specification consists of a percent sign
72.Dq Ql %
73and one other character.
74.Pp
75No more than
76.Fa maxsize
77characters will be placed into the array.
78If the total number of resulting characters, including the terminating
79NUL character, is not more than
80.Fa maxsize ,
81.Fn strftime
82returns the number of characters in the array, not counting the
83terminating NUL.
9385eb3d 84Otherwise, zero is returned and the buffer contents are indeterminate.
5b2abdfb
A
85.Pp
86The conversion specifications are copied to the buffer after expansion
87as follows:-
88.Bl -tag -width "xxxx"
89.It Cm \&%A
90is replaced by national representation of the full weekday name.
91.It Cm %a
92is replaced by national representation of
9385eb3d 93the abbreviated weekday name.
5b2abdfb
A
94.It Cm \&%B
95is replaced by national representation of the full month name.
96.It Cm %b
97is replaced by national representation of
9385eb3d 98the abbreviated month name.
5b2abdfb
A
99.It Cm \&%C
100is replaced by (year / 100) as decimal number; single
101digits are preceded by a zero.
102.It Cm %c
103is replaced by national representation of time and date.
5b2abdfb
A
104.It Cm \&%D
105is equivalent to
106.Dq Li %m/%d/%y .
107.It Cm %d
108is replaced by the day of the month as a decimal number (01-31).
109.It Cm \&%E* Cm \&%O*
110POSIX locale extensions.
111The sequences
112%Ec %EC %Ex %EX %Ey %EY
113%Od %Oe %OH %OI %Om %OM
114%OS %Ou %OU %OV %Ow %OW %Oy
115are supposed to provide alternate
116representations.
117.Pp
9385eb3d
A
118Additionly %OB implemented
119to represent alternative months names
5b2abdfb
A
120(used standalone, without day mentioned).
121.It Cm %e
122is replaced by the day of month as a decimal number (1-31); single
123digits are preceded by a blank.
9385eb3d
A
124.It Cm \&%F
125is equivalent to
126.Dq Li %Y-%m-%d .
5b2abdfb
A
127.It Cm \&%G
128is replaced by a year as a decimal number with century.
129This year is the one that contains the greater part of
130the week (Monday as the first day of the week).
131.It Cm %g
132is replaced by the same year as in
133.Dq Li %G ,
134but as a decimal number without century (00-99).
135.It Cm \&%H
136is replaced by the hour (24-hour clock) as a decimal number (00-23).
137.It Cm %h
138the same as %b.
139.It Cm \&%I
140is replaced by the hour (12-hour clock) as a decimal number (01-12).
141.It Cm %j
142is replaced by the day of the year as a decimal number (001-366).
143.It Cm %k
144is replaced by the hour (24-hour clock) as a decimal number (0-23);
145single digits are preceded by a blank.
146.It Cm %l
147is replaced by the hour (12-hour clock) as a decimal number (1-12);
148single digits are preceded by a blank.
149.It Cm \&%M
150is replaced by the minute as a decimal number (00-59).
151.It Cm %m
152is replaced by the month as a decimal number (01-12).
153.It Cm %n
154is replaced by a newline.
155.It Cm \&%O*
156the same as %E*.
157.It Cm %p
158is replaced by national representation of either
159"ante meridiem"
160or
161"post meridiem"
162as appropriate.
163.It Cm \&%R
164is equivalent to
165.Dq Li %H:%M .
166.It Cm %r
167is equivalent to
168.Dq Li %I:%M:%S %p .
169.It Cm \&%S
170is replaced by the second as a decimal number (00-60).
171.It Cm %s
172is replaced by the number of seconds since the Epoch, UTC (see
173.Xr mktime 3 ) .
174.It Cm \&%T
175is equivalent to
176.Dq Li %H:%M:%S .
177.It Cm %t
178is replaced by a tab.
179.It Cm \&%U
180is replaced by the week number of the year (Sunday as the first day of
181the week) as a decimal number (00-53).
182.It Cm %u
183is replaced by the weekday (Monday as the first day of the week)
184as a decimal number (1-7).
185.It Cm \&%V
186is replaced by the week number of the year (Monday as the first day of
3d9156a7
A
187the week) as a decimal number (01-53).
188If the week containing January
5b2abdfb
A
1891 has four or more days in the new year, then it is week 1; otherwise
190it is the last week of the previous year, and the next week is week 1.
191.It Cm %v
192is equivalent to
193.Dq Li %e-%b-%Y .
194.It Cm \&%W
195is replaced by the week number of the year (Monday as the first day of
196the week) as a decimal number (00-53).
197.It Cm %w
198is replaced by the weekday (Sunday as the first day of the week)
199as a decimal number (0-6).
200.It Cm \&%X
201is replaced by national representation of the time.
202.It Cm %x
203is replaced by national representation of the date.
204.It Cm \&%Y
205is replaced by the year with century as a decimal number.
206.It Cm %y
207is replaced by the year without century as a decimal number (00-99).
208.It Cm \&%Z
209is replaced by the time zone name.
210.It Cm \&%z
211is replaced by the time zone offset from UTC; a leading plus sign stands for
212east of UTC, a minus sign for west of UTC, hours and minutes follow
213with two digits each and no delimiter between them (common form for
214RFC 822 date headers).
215.It Cm %+
216is replaced by national representation of the date and time
217(the format is similar to that produced by
218.Xr date 1 ) .
219.It Cm %%
220is replaced by
221.Ql % .
222.El
223.Sh SEE ALSO
224.Xr date 1 ,
225.Xr printf 1 ,
226.Xr ctime 3 ,
227.Xr printf 3 ,
9385eb3d
A
228.Xr strptime 3 ,
229.Xr wcsftime 3
5b2abdfb
A
230.Sh STANDARDS
231The
232.Fn strftime
233function
234conforms to
235.St -isoC
236with 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
258The peculiar week number and year in the replacements of
259.Ql %G ,
260.Ql %g
261and
262.Ql \&%V
263are defined in ISO 8601: 1988.
264.Sh BUGS
265There is no conversion specification for the phase of the moon.
9385eb3d
A
266.Pp
267The
268.Fn strftime
269function does not correctly handle multibyte characters in the
270.Fa format
271argument.