add files fom from zcode2012e.tar.gz
[platform/upstream/tzdata.git] / newstrftime.3
1 .\" Based on the UCB file whose copyright information appears below.
2 .\" Copyright (c) 1989, 1991 The Regents of the University of California.
3 .\" All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" the American National Standards Committee X3, on Information
7 .\" Processing Systems.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\" 3. All advertising materials mentioning features or use of this software
18 .\"    must display the following acknowledgement:
19 .\"     This product includes software developed by the University of
20 .\"     California, Berkeley and its contributors.
21 .\" 4. Neither the name of the University nor the names of its contributors
22 .\"    may be used to endorse or promote products derived from this software
23 .\"    without specific prior written permission.
24 .\"
25 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 .\" SUCH DAMAGE.
36 .\"
37 .\"     from: @(#)strftime.3    5.12 (Berkeley) 6/29/91
38 .\"     $Id: strftime.3,v 1.4 1993/12/15 20:33:00 jtc Exp $
39 .\"
40 .TH NEWSTRFTIME 3
41 .SH NAME
42 strftime \- format date and time
43 .SH SYNOPSIS
44 .nf
45 .B #include <sys/types.h>
46 .B #include <time.h>
47 .PP
48 .B size_t strftime(buf, maxsize, format, timeptr)
49 .B char *buf;
50 .B size_t maxsize;
51 .B const char *format;
52 .B const struct tm *timeptr
53 .PP
54 .B cc ... -ltz
55 .fi
56 .SH DESCRIPTION
57 The
58 .I strftime\^
59 function formats the information from
60 .I timeptr\^
61 into the buffer
62 .I buf\^
63 according to the string pointed to by
64 .IR format\^ .
65 .PP
66 The
67 .I format\^
68 string consists of zero or more conversion specifications and
69 ordinary characters.
70 All ordinary characters are copied directly into the buffer.
71 A conversion specification consists of a percent sign
72 .Ql %
73 and one other character.
74 .PP
75 No more than
76 .I maxsize\^
77 characters are be placed into the array.
78 If the total number of resulting characters, including the terminating
79 null character, is not more than
80 .IR maxsize\^ ,
81 .I strftime\^
82 returns the number of characters in the array, not counting the
83 terminating null.
84 Otherwise, zero is returned.
85 .PP
86 Each conversion specification is replaced by the characters as
87 follows which are then copied into the buffer.
88 .TP
89 %A
90 is replaced by the locale's full weekday name.
91 .TP
92 %a
93 is replaced by the locale's abbreviated weekday name.
94 .TP
95 %B
96 is replaced by the locale's full month name.
97 .TP
98 %b or %h
99 is replaced by the locale's abbreviated month name.
100 .TP
101 %C
102 is replaced by the century (a year divided by 100 and truncated to an integer)
103 as a decimal number (00-99).
104 .TP
105 %c
106 is replaced by the locale's appropriate date and time representation.
107 .TP
108 %D
109 is replaced by the date in the format %m/%d/%y.
110 .TP
111 %d
112 is replaced by the day of the month as a decimal number (01-31).
113 .TP
114 %e
115 is replaced by the day of month as a decimal number (1-31);
116 single digits are preceded by a blank.
117 .TP
118 %F
119 is replaced by the date in the format %Y-%m-%d.
120 .TP
121 %G
122 is replaced by the ISO 8601 year with century as a decimal number.
123 .TP
124 %g
125 is replaced by the ISO 8601 year without century as a decimal number (00-99).
126 .TP
127 %H
128 is replaced by the hour (24-hour clock) as a decimal number (00-23).
129 .TP
130 %I
131 is replaced by the hour (12-hour clock) as a decimal number (01-12).
132 .TP
133 %j
134 is replaced by the day of the year as a decimal number (001-366).
135 .TP
136 %k
137 is replaced by the hour (24-hour clock) as a decimal number (0-23);
138 single digits are preceded by a blank.
139 .TP
140 %l
141 is replaced by the hour (12-hour clock) as a decimal number (1-12);
142 single digits are preceded by a blank.
143 .TP
144 %M
145 is replaced by the minute as a decimal number (00-59).
146 .TP
147 %m
148 is replaced by the month as a decimal number (01-12).
149 .TP
150 %n
151 is replaced by a newline.
152 .TP
153 %p
154 is replaced by the locale's equivalent of either AM or PM.
155 .TP
156 %R
157 is replaced by the time in the format %H:%M.
158 .TP
159 %r
160 is replaced by the locale's representation of 12-hour clock time
161 using AM/PM notation.
162 .TP
163 %S
164 is replaced by the second as a decimal number (00-60).
165 .TP
166 %s
167 is replaced by the number of seconds since the Epoch, UTC (see mktime(3)).
168 .TP
169 %T
170 is replaced by the time in the format %H:%M:%S.
171 .TP
172 %t
173 is replaced by a tab.
174 .TP
175 %U
176 is replaced by the week number of the year (Sunday as the first day of
177 the week) as a decimal number (00-53).
178 .TP
179 %u
180 is replaced by the weekday (Monday as the first day of the week)
181 as a decimal number (1-7).
182 .TP
183 %V
184 is replaced by the week number of the year (Monday as the first day of
185 the week) as a decimal number (01-53).  If the week containing January
186 1 has four or more days in the new year, then it is week 1; otherwise
187 it is week 53 of the previous year, and the next week is week 1.
188 .TP
189 %W
190 is replaced by the week number of the year (Monday as the first day of
191 the week) as a decimal number (00-53).
192 .TP
193 %w
194 is replaced by the weekday (Sunday as the first day of the week)
195 as a decimal number (0-6).
196 .TP
197 %X
198 is replaced by the locale's appropriate time representation.
199 .TP
200 %x
201 is replaced by the locale's appropriate date representation.
202 .TP
203 %Y
204 is replaced by the year with century as a decimal number.
205 .TP
206 %y
207 is replaced by the year without century as a decimal number (00-99).
208 .TP
209 %Z
210 is replaced by the time zone name,
211 or by the empty string if this is not determinable.
212 .TP
213 %z
214 is replaced by the offset from UTC in the format +HHMM or -HHMM as appropriate,
215 with positive values representing locations east of Greenwich,
216 or by the empty string if this is not determinable.
217 .TP
218 %%
219 is replaced by a single %.
220 .TP
221 %+
222 is replaced by the date and time in date(1) format.
223 .SH SEE ALSO
224 date(1),
225 getenv(3),
226 newctime(3),
227 newtzset(3),
228 time(2),
229 tzfile(5)