1 .\" Copyright (c) 1989, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" the American National Standards Committee X3, on Information
6 .\" Processing Systems.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
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.
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
36 .\" @(#)newstrftime.3 8.1
37 .\" $FreeBSD: src/lib/libc/stdtime/strftime.3,v 1.18.2.10 2003/05/24 00:01:31 keramida Exp $
38 .\" $DragonFly: src/lib/libc/stdtime/strftime.3,v 1.4 2008/10/19 20:15:58 swildner Exp $
45 .Nd format date and time
52 .Fa "char * restrict buf"
54 .Fa "const char * restrict format"
55 .Fa "const struct tm * restrict timeptr"
60 function formats the information from
64 according to the string pointed to by
69 string consists of zero or more conversion specifications and
71 All ordinary characters are copied directly into the buffer.
72 A conversion specification consists of a percent sign
74 and one other character.
78 characters will be placed into the array.
79 If the total number of resulting characters, including the terminating
80 NUL character, is not more than
83 returns the number of characters in the array, not counting the
85 Otherwise, zero is returned and the buffer contents are indeterminate.
87 The conversion specifications are copied to the buffer after expansion
89 .Bl -tag -width "xxxx"
91 is replaced by national representation of the full weekday name.
93 is replaced by national representation of
94 the abbreviated weekday name.
96 is replaced by national representation of the full month name.
98 is replaced by national representation of
99 the abbreviated month name.
101 is replaced by (year / 100) as decimal number; single
102 digits are preceded by a zero.
104 is replaced by national representation of time and date.
109 is replaced by the day of the month as a decimal number (01-31).
110 .It Cm \&%E* Cm \&%O*
111 POSIX locale extensions.
113 %Ec %EC %Ex %EX %Ey %EY
114 %Od %Oe %OH %OI %Om %OM
115 %OS %Ou %OU %OV %Ow %OW %Oy
116 are supposed to provide alternate
119 Additionally %OB implemented
120 to represent alternative months names
121 (used standalone, without day mentioned).
123 is replaced by the day of month as a decimal number (1-31); single
124 digits are preceded by a blank.
126 is replaced by the date in the format
129 is replaced by a year as a decimal number with century.
130 This year is the one that contains the greater part of
131 the week (Monday as the first day of the week).
133 is replaced by the same year as in
135 but as a decimal number without century (00-99).
137 is replaced by the hour (24-hour clock) as a decimal number (00-23).
141 is replaced by the hour (12-hour clock) as a decimal number (01-12).
143 is replaced by the day of the year as a decimal number (001-366).
145 is replaced by the hour (24-hour clock) as a decimal number (0-23);
146 single digits are preceded by a blank.
148 is replaced by the hour (12-hour clock) as a decimal number (1-12);
149 single digits are preceded by a blank.
151 is replaced by the minute as a decimal number (00-59).
153 is replaced by the month as a decimal number (01-12).
155 is replaced by a newline.
159 is replaced by national representation of either
171 is replaced by the second as a decimal number (00-60).
173 is replaced by the number of seconds since the Epoch, UTC (see
179 is replaced by a tab.
181 is replaced by the week number of the year (Sunday as the first day of
182 the week) as a decimal number (00-53).
184 is replaced by the weekday (Monday as the first day of the week)
185 as a decimal number (1-7).
187 is replaced by the week number of the year (Monday as the first day of
188 the week) as a decimal number (01-53). If the week containing January
189 1 has four or more days in the new year, then it is week 1; otherwise
190 it is the last week of the previous year, and the next week is week 1.
195 is replaced by the week number of the year (Monday as the first day of
196 the week) as a decimal number (00-53).
198 is replaced by the weekday (Sunday as the first day of the week)
199 as a decimal number (0-6).
201 is replaced by national representation of the time.
203 is replaced by national representation of the date.
205 is replaced by the year with century as a decimal number.
207 is replaced by the year without century as a decimal number (00-99).
209 is replaced by the time zone name,
210 or by the empty string if this is not determinable.
212 is replaced by the offset from UTC in the format
217 with positive values representing locations east of Greenwich,
218 or by the empty string if this is not determinable.
220 is replaced by national representation of the date and time
221 (the format is similar to that produced by
239 with a lot of extensions including
261 The peculiar week number and year in the replacements of
266 are defined in ISO 8601: 1988.
268 There is no conversion specification for the phase of the moon.