OSDN Git Service

(split) Apply minor changes from v3.32 to v3.35 in the upstream.
[linuxjm/LDP_man-pages.git] / draft / man3 / strftime.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\"     GNU texinfo documentation on glibc date/time functions.
28 .\" Modified Sat Jul 24 18:03:44 1993 by Rik Faith (faith@cs.unc.edu)
29 .\" Applied fix by Wolfgang Franke, aeb, 961011
30 .\" Corrected return value, aeb, 970307
31 .\" Added Single UNIX Spec conversions and %z, aeb/esr, 990329.
32 .\" 2005-11-22 mtk, added Glibc Notes covering optional 'flag' and
33 .\"           'width' components of conversion specifications.
34 .\"
35 .\" Japanese Version Copyright (c) 2000 HANATAKA Shinya
36 .\"         all rights reserved.
37 .\" Translated 2000-10-10, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
38 .\" Updated 2002-01-09, Kentaro Shirakata <argrath@ub32.org>
39 .\" Updated 2002-01-14, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
40 .\" Updated 2005-02-26, Akihiro MOTOKI
41 .\" Updated 2005-04-17, Akihiro MOTOKI
42 .\" Updated 2005-12-05, Akihiro MOTOKI, LDP v2.16
43 .\" Updated 2010-04-18, Akihiro MOTOKI, LDP v3.24
44 .\"
45 .\"WORD:        conversion specifier            ÊÑ´¹»ØÄêʸ»ú
46 .\"WORD:        conversion specification        ÊÑ´¹»ØÄê
47 .\"WORD:        modifier                        ½¤¾þ»Ò
48 .\"WORD:        broken-down time                Í×ÁÇÊ̤Î(»þ¹ï)
49 .\"WORD:        Single UNIX Specification       Åý°ì UNIX µ¬³Ê
50 .\"WORD:        ISO\ 8601 week-based            ISO\ 8601 ¤Î½µÃ±°Ìɽµ­
51 .\"
52 .TH STRFTIME 3  2010-01-17 "GNU" "Linux Programmer's Manual"
53 .SH Ì¾Á°
54 .\"O strftime \- format date and time
55 strftime \- ÆüÉÕ¤ª¤è¤Ó»þ¹ï¤Îʸ»úÎó¤Ø¤ÎÊÑ´¹
56 .SH ½ñ¼°
57 .nf
58 .B #include <time.h>
59 .sp
60 .BI "size_t strftime(char *" s ", size_t " max ", const char *" format ,
61 .BI "                const struct tm *" tm );
62 .fi
63 .SH ÀâÌÀ
64 .\"O The
65 .\"O .BR strftime ()
66 .\"O function formats the broken-down time \fItm\fP
67 .\"O according to the format specification \fIformat\fP and places the
68 .\"O result in the character array \fIs\fP of size \fImax\fP.
69 .BR strftime ()
70 ´Ø¿ô ¤Ï¡¢Í×ÁÇÊ̤λþ¹ï \fItm\fP ¤ÎÆâÍƤò
71 \fIformat\fP ¤Ç»ØÄꤵ¤ì¤¿½ñ¼°»ØÄê¤Ë¤·¤¿¤¬¤Ã¤ÆÊÑ´¹¤·¡¢
72 Ťµ \fImax\fP ¤Îʸ»úÎó \fIs\fP ¤Ë½ñ¤­¹þ¤à¡£
73 .\" FIXME POSIX says: Local timezone information is used as though
74 .\" strftime() called tzset().  But this doesn't appear to be the case
75 .PP
76 .\"O The format specification is a null-terminated string and may contain
77 .\"O special character sequences called
78 .\"O .IR "conversion specifications",
79 .\"O each of which is introduced by a \(aq%\(aq character and terminated by
80 .\"O some other character known as a
81 .\"O .IR "conversion specifier character".
82 .\"O All other character sequences are
83 .\"O .IR "ordinary character sequences".
84 ½ñ¼°»ØÄê¤Ï NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤Ç¤¢¤ê¡¢
85 ¡ÖÊÑ´¹»ØÄê (conversion specification)¡×¤È¸Æ¤Ð¤ì¤ëÆÃÊ̤Êʸ»úÎó¤ò
86 ´Þ¤Þ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
87 ³Æ¡¹¤ÎÊÑ´¹»ØÄê¤Ï \(aq%\(aq Ê¸»ú¤Ç»Ï¤Þ¤ê¡¢
88 ¡ÖÊÑ´¹»ØÄêʸ»ú (conversion specifier character)¡×¤È¸Æ¤Ð¤ì¤ë
89 ²¿¤é¤«Â¾¤Îʸ»ú¤Ç½ªÃ¼¤µ¤ì¤ë¡£¾åµ­°Ê³°¤ÎÁ´¤Æ¤Îʸ»úÎó¤Ï
90 ¡ÖÄ̾ï¤Îʸ»úÎó (ordinary character sequence)¡×¤È¤Ê¤ë¡£
91 .PP
92 .\"O The characters of ordinary character sequences (including the null byte)
93 .\"O are copied verbatim from \fIformat\fP to \fIs\fP. However, the characters
94 .\"O of conversion specifications are replaced as follows:
95 (NULL ¥Ð¥¤¥È¤â´Þ¤à) Ä̾ï¤Îʸ»úÎóÆâ¤Îʸ»ú¤Ï¡¢
96 ¤½¤Î¤Þ¤Þ \fIformat\fP ¤«¤é \fIs\fP ¤Ë¥³¥Ô¡¼¤µ¤ì¤ë¡£
97 °ìÊý¡¢ÊÑ´¹»ØÄê¤Îʸ»ú¤Ï°Ê²¼¤Î¤è¤¦¤ËÃÖ´¹¤µ¤ì¤ë¡£
98 .TP
99 .B %a
100 .\"O The abbreviated weekday name according to the current locale.
101 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ëÍËÆü¤Î¾Êά̾¡£
102 .TP
103 .B %A
104 .\"O The full weekday name according to the current locale.
105 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ëÍËÆü¤Î´°Á´¤Ê̾Á°¡£
106 .TP
107 .B %b
108 .\"O The abbreviated month name according to the current locale.
109 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ë·î¤Î¾Êά̾¡£
110 .TP
111 .B %B
112 .\"O The full month name according to the current locale.
113 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ë·î¤Î´°Á´¤Ê̾Á°¡£
114 .TP
115 .B %c
116 .\"O The preferred date and time representation for the current locale.
117 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤¤¤Æ°ìÈÌŪ¤ÊÆüÉÕ¡¦»þ¹ï¤Îɽµ­¡£
118 .TP
119 .B %C
120 .\"O The century number (year/100) as a 2-digit integer. (SU)
121 À¤µª (À¾Îñǯ¤Î¾å 2 ·å)¡£ (SU)
122 .TP
123 .B %d
124 .\"O The day of the month as a decimal number (range 01 to 31).
125 ·îÆâÄÌ»»Æü (10 ¿Ê¿ôɽµ­) (01-31)¡£
126 .TP
127 .B %D
128 .\"O Equivalent to
129 .\"O .BR %m/%d/%y .
130 .\"O (Yecch\(emfor Americans only.
131 .\"O Americans should note that in other countries
132 .\"O .B %d/%m/%y
133 .\"O is rather common.
134 .\"O ambiguous and should not be used.) (SU)
135 .B %m/%d/%y
136 ¤ÈÅù²Á¡£(¤¦¤¨¤Ã¡¢¥¢¥á¥ê¥«ÀìÍѤÀ¡£¥¢¥á¥ê¥«°Ê³°¤Î¹ñ¤Ç¤Ï
137 .B %d/%m/%y
138 ¤ÎÊý¤¬°ìÈÌŪ¤À¡£Ê¶¤é¤ï¤·¤¤¤Î¤Ç¡¢»ÈÍѤ¹¤Ù¤­¤Ç¤Ï¤Ê¤¤¡£) (SU)
139 .TP
140 .B %e
141 .\"O Like
142 .\"O .BR %d ,
143 .\"O the day of the month as a decimal number, but a leading
144 .\"O zero is replaced by a space. (SU)
145 .B %d
146 ¤ÈƱÍͤ˷îÆâÄÌ»»Æü¤ò 10 ¿Ê¿ô¤Çɽ¸½¤¹¤ë¤¬¡¢
147 1 ·å¤Î¾ì¹ç 10 ¤Î°Ì¤Ë¥¼¥í¤òÃÖ¤«¤º¥¹¥Ú¡¼¥¹¤òÃÖ¤¯¡£(SU)
148 .TP
149 .B %E
150 .\"O Modifier: use alternative format, see below. (SU)
151 ÊÌ·Á¼°¤ò»ÈÍѤ¹¤ëºÝ¤Î½¤¾þ»Ò¡£²¼µ­»²¾È¡£ (SU)
152 .TP
153 .B %F
154 .\"O Equivalent to
155 .\"O .B %Y-%m-%d
156 .\"O (the ISO\ 8601 date format). (C99)
157 .B %Y-%m-%d
158 ¤ÈÅù²Á (ISO\ 8601 ·Á¼°¤ÎÆüÉÕ¥Õ¥©¡¼¥Þ¥Ã¥È)¡£ (C99)
159 .TP
160 .B %G
161 .\"O The ISO\ 8601 week-based year (see NOTES) with century as a decimal number.
162 .\"O The 4-digit year corresponding to the ISO week number (see
163 .\"O .BR %V ).
164 .\"O This has the same format and value as
165 .\"O .BR %Y ,
166 .\"O except that if the ISO week number belongs to the previous or next year,
167 .\"O that year is used instead. (TZ)
168 ISO\ 8601 ½µÃ±°Ìɽµ­¤Îǯ (week-based year; ¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È)¡£
169 À¤µª¤â 10 ¿Ê¿ô¤Çɽ¤¹¡£
170 ISO ½µÈÖ¹æ
171 .RB ( %V
172 ¤ò»²¾È) ¤ËÂбþ¤·¤¿ 4 ·å¤ÎÀ¾Îñǯ¡£
173 ¤³¤ì¤Ï´ðËÜŪ¤Ë¤Ï
174 .B %Y
175 ¤ÈƱ¤¸·Á¼°¤À¤¬¡¢ISO ½µ¿ô¤¬Á°Ç¯¤äÍâǯ¤Ë¤Ê¤ë
176 ¾ì¹ç¤Ë¤Ï¤½¤Îǯ¤¬»ÈÍѤµ¤ì¤ëÅÀ¤¬°Û¤Ê¤ë¡£(TZ)
177 .TP
178 .B %g
179 .\"O Like
180 .\"O .BR %G ,
181 .\"O but without century, that is, with a 2-digit year (00-99). (TZ)
182 .B %G
183 ¤ÈƱÍÍ¡£Ã¢¤·¡¢À¤µª¤ò´Þ¤Þ¤º²¼ 2 ·å¤Î¤ß¤òɽ¼¨ (00-99)¡£ (TZ)
184 .TP
185 .B %h
186 .\"O Equivalent to
187 .\"O .BR %b .
188 .\"O (SU)
189 .B %b
190 ¤ÈÅù²Á (SU)
191 .TP
192 .B %H
193 .\"O The hour as a decimal number using a 24-hour clock (range 00 to 23).
194 24 »þ´Öɽµ­¤Ç¤Î»þ (hour)¡£ (00-23)
195 .TP
196 .B %I
197 .\"O The hour as a decimal number using a 12-hour clock (range 01 to 12).
198 12 »þ´Öɽµ­¤Ç¤Î»þ (hour)¡£ (01-12)
199 .TP
200 .B %j
201 .\"O The day of the year as a decimal number (range 001 to 366).
202 ǯ¤Î½é¤á¤«¤éÄÌ»»¤ÎÆü¿ô¡£ (001-366)
203 .TP
204 .B %k
205 .\"O The hour (24-hour clock) as a decimal number (range 0 to 23);
206 .\"O single digits are preceded by a blank.
207 .\"O (See also
208 .\"O .BR %H .)
209 .\"O (TZ)
210 24 »þ´Öɽµ­¤Ç¤Î»þ (0-23)¡£
211 1 ·å¤Î¾ì¹ç¤Ë¤ÏÁ°¤Ë¥¼¥í¤Ç¤Ê¤¯¥¹¥Ú¡¼¥¹¤¬ÃÖ¤«¤ì¤ë¡£
212 .RB ( %H
213 ¤â»²¾È) (TZ)
214 .TP
215 .B %l
216 .\"O The hour (12-hour clock) as a decimal number (range 1 to 12);
217 .\"O single digits are preceded by a blank.
218 .\"O (See also
219 .\"O .BR %I .)
220 .\"O (TZ)
221 12 »þ´Öɽµ­¤Ç¤Î»þ (0-12)¡£
222 1 ·å¤Î¾ì¹ç¤Ë¤ÏÁ°¤Ë¥¼¥í¤Ç¤Ê¤¯¥¹¥Ú¡¼¥¹¤¬ÃÖ¤«¤ì¤ë¡£
223 .RB ( %I
224 ¤â»²¾È) (TZ)
225 .TP
226 .B %m
227 .\"O The month as a decimal number (range 01 to 12).
228 ·î (10 ¿Ê¿ôɽµ­)¡£ (01-12)
229 .TP
230 .B %M
231 .\"O The minute as a decimal number (range 00 to 59).
232 ʬ (10 ¿Ê¿ôɽµ­) (00-59)
233 .TP
234 .B %n
235 .\"O A newline character. (SU)
236 ²þ¹Ô¡£ (SU)
237 .TP
238 .B %O
239 .\"O Modifier: use alternative format, see below. (SU)
240 ÊÌ·Á¼°¤ò»ÈÍѤ¹¤ëºÝ¤Î½¤¾þ»Ò¡£°Ê²¼¤ò»²¾È¡£(SU)
241 .TP
242 .B %p
243 .\"O Either "AM" or "PM" according to the given time value, or the
244 .\"O corresponding strings for the current locale.
245 .\"O Noon is treated as "PM" and midnight as "AM".
246 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ë¡Ö¸áÁ°¡×¡Ö¸á¸å¡×¤ËÁêÅö¤¹¤ëʸ»úÎó¡£
247 ±Ñ¸ì¤Î¾ì¹ç¤Ë¤Ï "AM" ¤Þ¤¿¤Ï "PM" ¤È¤Ê¤ë¡£
248 Àµ¸á¤Ï¡Ö¸á¸å¡×¡¢¿¿ÌëÃæ¤Ï¡Ö¸áÁ°¡×¤È¤·¤Æ°·¤ï¤ì¤ë¡£
249 .TP
250 .B %P
251 .\"O Like
252 .\"O .B %p
253 .\"O but in lowercase: "am" or "pm" or a corresponding
254 .\"O string for the current locale. (GNU)
255 .B %p
256 ¤ÈƱÍͤǤ¢¤ë¤¬¾®Ê¸»ú¤¬»ÈÍѤµ¤ì¤ë¡£
257 ±Ñ¸ì¤Î¾ì¹ç¤Ë¤Ï "am" ¤ä "pm" ¤È¤Ê¤ë¡£(GNU)
258 .TP
259 .B %r
260 .\"O The time in a.m. or p.m. notation.
261 .\"O In the POSIX locale this is equivalent to
262 .\"O .BR "%I:%M:%S %p" .
263 .\"O (SU)
264 ¸áÁ°¡¦¸á¸å·Á¼°¤Ç¤Î»þ¹ï¡£
265 POSIX ¥í¥±¡¼¥ë¤Ç¤Ï
266 .B "%I:%M:%S %p"
267 ¤ÈÅù²Á¤Ç¤¢¤ë¡£(SU)
268 .TP
269 .B %R
270 .\"O The time in 24-hour notation (\fB%H:%M\fP). (SU)
271 .\"O For a version including the seconds, see
272 .\"O .B %T
273 .\"O below.
274 24 »þ´Öɽµ­¤Ç¤Î»þ¹ï¡¢ÉäÏɽ¼¨¤·¤Ê¤¤
275 .RB ( %H:%M )¡£
276 Éäò´Þ¤ó¤À¤â¤Î¤Ï°Ê²¼¤Î
277 .B %T
278 ¤ò»²¾È¤¹¤ë¤³¤È¡£(SU)
279 .TP
280 .B %s
281 .\"O The number of seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC). (TZ)
282 µª¸µ (Epoch; 1970-01-01 00:00:00 +0000 (UTC)) ¤«¤é¤ÎÉÿô¡£ (TZ)
283 .TP
284 .B %S
285 .\"O The second as a decimal number (range 00 to 60).
286 .\"O (The range is up to 60 to allow for occasional leap seconds.)
287 Éà(10 ¿Ê¿ôɽµ­) (00-60)
288 (»þ¡¹¤¢¤ë±¼ÉäËÂбþ¤¹¤ë¤¿¤á¡¢ÃͤÎÈϰϤϠ60 ¤Þ¤Ç¤È¤Ê¤Ã¤Æ¤¤¤ë)
289 .TP
290 .B %t
291 .\"O A tab character. (SU)
292 ¥¿¥Öʸ»ú (SU)
293 .TP
294 .B %T
295 .\"O The time in 24-hour notation (\fB%H:%M:%S\fP). (SU)
296 24 »þ´Öɽµ­¤Î»þ´Ö (\fB%H:%M:%S\fP) (SU)
297 .TP
298 .B %u
299 .\"O The day of the week as a decimal, range 1 to 7, Monday being 1.
300 .\"O See also
301 .\"O .BR %w .
302 .\"O (SU)
303 ½µ¤Î²¿ÈÖÌܤÎÆü (10 ¿Ê¿ôɽµ­) ¤«¡£·îÍËÆü¤ò 1 ¤È¤¹¤ë (1-7)¡£
304 .B %w
305 ¤â»²¾È¡£(SU)
306 .TP
307 .B %U
308 .\"O The week number of the current year as a decimal number,
309 .\"O range 00 to 53, starting with the first Sunday as the first day
310 .\"O of week 01.
311 .\"O See also
312 .\"O .B %V
313 .\"O and
314 .\"O .BR %W .
315 ǯ¤Î½é¤á¤«¤é¤ÎÄÌ»»¤Î½µÈÖ¹æ (10 ¿Ê¿ôɽµ­) (00-53)¡£
316 ¤½¤Îǯ¤ÎºÇ½é¤ÎÆüÍËÆü¤ò¡¢Âè 1 ½µ¤Î»Ï¤Þ¤ê¤È¤·¤Æ·×»»¤¹¤ë¡£
317 .B %V
318 ¤È
319 .B %W
320 ¤â»²¾È¤¹¤ë¤³¤È¡£
321 .TP
322 .B %V
323 .\"O The ISO\ 8601 week number (see NOTES) of the current year as a decimal number,
324 .\"O range 01 to 53, where week 1 is the first week that has at least
325 .\"O 4 days in the new year.
326 .\"O See also
327 .\"O .B %U
328 .\"O and
329 .\"O .BR %W .
330 .\"O (SU)
331 ISO\ 8601 ·Á¼°¤Ç¤Îǯ¤Î»Ï¤á¤«¤é¤Î½µÈÖ¹æ (¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È)¡£
332 10 ¿Ê¿ôɽµ­¤Ç¡¢01 ¤«¤é 53 ¤ÎÃͤȤʤ롣½µÈÖ¹æ¤Ï¡¢
333 ¿·¤·¤¤Ç¯¤¬¾¯¤Ê¤¯¤È¤â 4 Æü°Ê¾å´Þ¤Þ¤ì¤ëºÇ½é¤Î½µ¤ò 1 ¤È¤·¤Æ·×»»¤¹¤ë¡£
334 .B %U
335 ¤È
336 .B %W
337 ¤â»²¾È¤Î¤³¤È¡£(SU)
338 .TP
339 .B %w
340 .\"O The day of the week as a decimal, range 0 to 6, Sunday being 0.
341 .\"O See also
342 .\"O .BR %u .
343 ½µ¤Î²¿ÈÖÌܤÎÆü (10 ¿Ê¿ôɽµ­) ¤«¡£ÆüÍËÆü¤ò 0 ¤È¤¹¤ë¡£(0-6)¡£
344 .B %u
345 ¤â»²¾È¡£(SU)
346 .TP
347 .B %W
348 .\"O The week number of the current year as a decimal number,
349 .\"O range 00 to 53, starting with the first Monday as the first day of week 01.
350 ǯ¤Î½é¤á¤«¤é¤ÎÄÌ»»¤Î½µÈÖ¹æ (10 ¿Ê¿ôɽµ­) (00-53)¡£
351 ¤½¤Îǯ¤ÎºÇ½é¤Î·îÍËÆü¤ò¡¢Âè 1 ½µ¤Î»Ï¤Þ¤ê¤È¤·¤Æ·×»»¤¹¤ë¡£
352 .TP
353 .B %x
354 .\"O The preferred date representation for the current locale without the time.
355 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ç°ìÈÌŪ¤ÊÆüÉÕɽµ­¡£»þ¹ï¤Ï´Þ¤Þ¤Ê¤¤¡£
356 .TP
357 .B %X
358 .\"O The preferred time representation for the current locale without the date.
359 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ç°ìÈÌŪ¤Ê»þ¹ïɽµ­¡£ÆüÉդϴޤޤʤ¤¡£
360 .TP
361 .B %y
362 .\"O The year as a decimal number without a century (range 00 to 99).
363 À¾Îñ¤Î²¼2·å (À¤µªÉôʬ¤ò´Þ¤Þ¤Ê¤¤Ç¯) (00-99)¡£
364 .TP
365 .B %Y
366 .\"O The year as a decimal number including the century.
367 À¤µªÉôʬ¤ò´Þ¤á¤¿ ( 4 ·å¤Î) À¾Îñǯ¡£
368 .TP
369 .B %z
370 .\"O The
371 .\"O .I +hhmm
372 .\"O or
373 .\"O .I -hhmm
374 .\"O numeric timezone (that is, the hour and minute offset from UTC). (SU)
375 .I +hhmm
376 ¤ä
377 .I -hhmm
378 ¤Î·Á¼°¤Î¥¿¥¤¥à¥¾¡¼¥ó (UTC ¤Ø¤Î¥ª¥Õ¥»¥Ã¥È»þ´Ö)¡£(SU)
379 .TP
380 .B %Z
381 .\"O The timezone or name or abbreviation.
382 ¥¿¥¤¥à¥¾¡¼¥ó¤Þ¤¿¤Ï¥¾¡¼¥ó̾¤Þ¤¿¤Ï¾Êά̾¡£
383 .TP
384 .B %+
385 .\" Nov 05 -- Not in Linux/glibc, but is in some BSDs (according to
386 .\" their man pages)
387 .\"O The date and time in
388 .\"O .BR date (1)
389 .\"O format. (TZ)
390 .\"O (Not supported in glibc2.)
391 .BR date (1)
392 ·Á¼°¤Ç¤ÎÆü»þ¡£(TZ)
393 (glibc2 ¤Ç¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤)
394 .TP
395 .B %%
396 .\"O A literal \(aq%\(aq character.
397 \(aq%\(aq Ê¸»ú¡£
398 .PP
399 .\"O Some conversion specifications can be modified by preceding the
400 .\"O conversion specifier character by the
401 .\"O .B E
402 .\"O or
403 .\"O .B O
404 .\"O .I modifier
405 .\"O to indicate that an alternative format should be used.
406 ¤¤¤¯¤Ä¤«¤ÎÊÑ´¹»ØÄê¤Ç¤Ï¡¢ÊÑ´¹»ØÄêʸ»ú¤ÎÁ°¤Ë
407 .B E
408 ¤ä
409 .B O
410 ¡Ö½¤¾þ»Ò¡×¤òÃÖ¤¯¤³¤È¤Ë¤è¤Ã¤ÆÊ̽ñ¼°¤ò»ÈÍѤ¹¤ë¤è¤¦¤Ë»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
411 .\"O If the alternative format or specification does not exist for
412 .\"O the current locale, the behavior will be as if the unmodified
413 .\"O conversion specification were used. (SU)
414 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤¤¤ÆÊ̽ñ¼°¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢
415 Ä̾ï¤ÎÊÑ´¹»ØÄ꤬»ÈÍѤµ¤ì¤¿¤«¤Î¤è¤¦¤ËÆ°ºî¤¹¤ë (SU)¡£
416 .\"O The Single UNIX Specification mentions
417 .\"O .BR %Ec ,
418 .\"O .BR %EC ,
419 .\"O .BR %Ex ,
420 .\"O .BR %EX ,
421 .\"O .BR %Ey ,
422 .\"O .BR %EY ,
423 .\"O .BR %Od ,
424 .\"O .BR %Oe ,
425 .\"O .BR %OH ,
426 .\"O .BR %OI ,
427 .\"O .BR %Om ,
428 .\"O .BR %OM ,
429 .\"O .BR %OS ,
430 .\"O .BR %Ou ,
431 .\"O .BR %OU ,
432 .\"O .BR %OV ,
433 .\"O .BR %Ow ,
434 .\"O .BR %OW ,
435 .\"O .BR %Oy ,
436 .\"O where the effect of the
437 .\"O .B O
438 .\"O modifier is to use
439 .\"O alternative numeric symbols (say, roman numerals), and that of the
440 .\"O E modifier is to use a locale-dependent alternative representation.
441 Åý°ì UNIX µ¬³Ê (Single UNIX Specification) ¤Ç¤Ï
442 .BR %Ec ,
443 .BR %EC ,
444 .BR %Ex ,
445 .BR %EX ,
446 .BR %Ey ,
447 .BR %EY ,
448 .BR %Od ,
449 .BR %Oe ,
450 .BR %OH ,
451 .BR %OI ,
452 .BR %Om ,
453 .BR %OM ,
454 .BR %OS ,
455 .BR %Ou ,
456 .BR %OU ,
457 .BR %OV ,
458 .BR %Ow ,
459 .BR %OW ,
460 .BR %Oy ,
461 ¤Ë¤Ä¤¤¤Æµ­½Ò¤¬¤¢¤ë¡£¤³¤³¤Ç
462 .B O
463 ½¤¾þ»Ò¤ÏÊÌ·Á¼°¤Î¿ôÃÍ (¥í¡¼¥Þ¿ô»ú¤È¤«) ¤ò»ØÄꤹ¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¡£
464 .B E
465 ½¤¾þ»Ò¤Ï¥í¥±¡¼¥ë°Í¸¤ÎÊÌɽ¸½¤ò»ØÄꤹ¤ë¤Î¤Ë»ÈÍѤ¹¤ë¡£
466 (ÌõÃí:
467 .B E
468 ½¤¾þ»Ò¤ÏÆüËܤǻÈÍѤµ¤ì¤Æ¤¤¤ë¡Ö¾¼Ï¡סÖÊ¿À®¡×
469 ¤Ê¤É¤Î¸µ¹æ¤Ë¤è¤ëǯɽµ­¤ò»ØÄꤹ¤ë¡£glibc 2.2 °Ê¹ß¤Ç¤Î¤ßÍ­¸ú)
470 .PP
471 .\"O The broken-down time structure \fItm\fP is defined in \fI<time.h>\fP.
472 .\"O See also
473 .\"O .BR ctime (3).
474 Í×ÁÇÊ̤λþ¹ï¹½Â¤ÂΠ\fItm\fP ¤Î¾ÜºÙ¤Ï \fI<time.h>\fP ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
475 .BR ctime (3)
476 ¤â»²¾È¤¹¤ë¤³¤È¡£
477 .\"O .SH "RETURN VALUE"
478 .SH ÊÖ¤êÃÍ
479 .\"O The
480 .\"O .BR strftime ()
481 .\"O function returns the number of characters placed
482 .\"O in the array \fIs\fP, not including the terminating null byte,
483 .\"O provided the string, including the terminating null byte, fits.
484 .BR strftime ()
485 ´Ø¿ô¤Ïʸ»úÎó \fIs\fP ¤Ë³ÊǼ¤µ¤ì¤¿Ê¸»ú¿ô¤òÊÖ¤¹¡£
486 ¤³¤Îʸ»ú¿ô¤Ë½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤Ï´Þ¤Þ¤Ê¤¤¡£
487 ½ªÃ¼¤Î NULL ¥Ð¥¤¥È¤ò³ÊǼ¤Ç¤­¤ë¤À¤±¤ÎÂ礭¤µ¤ò»ý¤Ã¤¿Ê¸»úÎó¤òÅϤ¹¤³¤È¡£
488 .\"O Otherwise, it returns 0, and the contents of the array is undefined.
489 .\"O (This behavior applies since at least libc 4.4.4;
490 .\"O very old versions of libc, such as libc 4.4.1,
491 .\"O would return \fImax\fP if the array was too small.)
492 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï 0 ¤òÊÖ¤·¡¢Ê¸»úÎó¤ÎÆâÍƤϽ¤Àµ¤µ¤ì¤Ê¤¤¡£
493 (libc 4.4.4 °Ê¹ß¤Ç¤³¤ÎµóÆ°¤¬Å¬ÍѤµ¤ì¤Æ¤¤¤ë¡£
494 libc 4.4.1 ¤Ê¤É¤ÎÈó¾ï¤Ë¸Å¤¤¥Ð¡¼¥¸¥ç¥ó¤Î libc ¤Ç¤Ï
495 ʸ»úÎó¤¬Ã»¤«²á¤®¤¿¾ì¹ç¤Ë¤Ï \fImax\fP ¤¬ÊÖ¤µ¤ì¤ë¡£)
496 .LP
497 .\"O Note that the return value 0 does not necessarily indicate an error;
498 .\"O for example, in many locales
499 .\"O .B %p
500 .\"O yields an empty string.
501 ÊÖ¤êÃÍ 0 ¤Ïɬ¤º¤·¤â¥¨¥é¡¼¤ò°ÕÌ£¤·¤Æ¤¤¤ëÌõ¤Ç¤Ï¤Ê¤¤¤Î¤ÇÃí°Õ¤¹¤ë¤³¤È¡£
502 Î㤨¤Ð¡¢Â¿¤¯¤Î¥í¥±¡¼¥ë¤Ç¤Ï
503 .B %p
504 ¤Ï¶õʸ»úÎó¤òÊÖ¤¹¡£
505 .\"O .SH ENVIRONMENT
506 .SH ´Ä¶­ÊÑ¿ô
507 .\"O The environment variables
508 .\"O .B TZ
509 .\"O and
510 .\"O .B LC_TIME
511 .\"O are used.
512 ´Ä¶­ÊÑ¿ô
513 .B TZ
514 ¤È
515 .B LC_TIME
516 ¤¬»ÈÍѤµ¤ì¤ë¡£
517 (ÌõÃí:
518 .B LC_ALL
519 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
520 .B LC_TIME
521 ¤è¤ê¤â¤½¤Á¤é¤¬Í¥À褵¤ì¤ë¡£
522 .B LC_TIME
523 ¤â
524 .B LC_ALL
525 ¤âÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï
526 .B LANG
527 ¤¬»ÈÍѤµ¤ì¤ë¡£)
528 .\"O .SH "CONFORMING TO"
529 .SH ½àµò
530 SVr4, C89, C99.
531 .\"O There are strict inclusions between the set of conversions
532 .\"O given in ANSI C (unmarked), those given in the Single UNIX Specification
533 .\"O (marked SU), those given in Olson's timezone package (marked TZ),
534 .\"O and those given in glibc (marked GNU), except that
535 .\"O .B %+
536 .\"O is not supported in glibc2.
537 .\"O On the other hand glibc2 has several more extensions.
538 .\"O POSIX.1 only refers to ANSI C; POSIX.2 describes under
539 .\"O .BR date (1)
540 .\"O several extensions that could apply to
541 .\"O .BR strftime ()
542 .\"O as well.
543 ¸Ä¡¹¤ÎÊÑ´¹¤¬¸·Ì©¤Ë¤É¤Îµ¬³Ê¤Ë´Þ¤Þ¤ì¤ë¤«¤Ï¡¢
544 ANSI C (°õ¤Ê¤·)¡¢Åý°ì UNIX µ¬³Ê (SU°õ)¡¢Olson ¤Î timezone ¥Ñ¥Ã¥±¡¼¥¸ (TZ°õ)¡¢
545 glibc Æȼ« (GNU°õ) ¤Ç¼¨¤·¤Æ¤¤¤ë¡£glibc2 ¤Ç¤Ï
546 .B %+
547 ¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
548 ¤¤¤¯¤Ä¤«¤Î³ÈÄ¥¤¬¹Ô¤ï¤ì¤Æ¤¤¤ë¡£POSIX.1 ¤Ç¤Ï ANSI C ¤Î¤ß¤ò»²¾È¤·¤Æ¤¤¤ë¡£
549 POSIX.2 ¤Î
550 .BR date (1)
551 ¤Î¤È¤³¤í¤Ëµ­½Ò¤µ¤ì¤Æ¤¤¤ë´ö¤Ä¤«¤Î³ÈÄ¥¤Ï
552 .BR strftime ()
553 ¤Ë¤âŬÍѤǤ­¤ë¤À¤í¤¦¡£
554 .\"O The
555 .\"O .B %F
556 .\"O conversion is in C99 and POSIX.1-2001.
557 .B %F
558 ÊÑ´¹¤Ï C99 ¤È POSIX.1-2001 ¤Ë¤¢¤ë¡£
559
560 .\"O In SUSv2, the
561 .\"O .B %S
562 .\"O specifier allowed a range of 00 to 61,
563 .\"O to allow for the theoretical possibility of a minute that
564 .\"O included a double leap second
565 .\"O (there never has been such a minute).
566 SUSv2 ¤Ç¤Ï¡¢
567 .B %S
568 ¤Ï 00 ¤«¤é 61 ¤ÎÈϰϤò¤È¤ë¤Èµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
569 ¤³¤ì¤Ï¡¢1ʬ´Ö¤Î¤¦¤Á±¼É䬠2¤ÄÆþ¤ë²ÄǽÀ­¤¬ÍýÏÀŪ¤Ë¤Ï¤¢¤ë¤³¤È¤ò
570 ¹Íθ¤·¤Æ¤Î¤â¤Î¤Ç¤¢¤ë (¼ÂºÝ¤Ë¤Ï¡¢¤³¤Î¤è¤¦¤Ê¾õ¶·¤Ï¤³¤ì¤Þ¤Ç°ìÅÙ¤â
571 µ¯¤³¤Ã¤Æ¤¤¤Ê¤¤)¡£
572 .\"O .SH NOTES
573 .SH Ãí°Õ
574 .\"O .SS ISO 8601 Week Dates
575 .SS ISO\ 8601 ¤Î½µ¡¦ÍËÆüɽµ­ (Week Dates)
576 .\"O .BR %G ,
577 .\"O .BR %g ,
578 .\"O and
579 .\"O .BR %V
580 .\"O yield values calculated from the week-based year defined by the
581 .\"O ISO\ 8601 standard.
582 .BR %G ,
583 .BR %g ,
584 .BR %V
585 ¤Ï¡¢ISO\ 8601 É¸½à¤Ë¤è¤êÄêµÁ¤µ¤ì¤¿½µÃ±°Ìɽµ­¤Îǯ¤Ë¤è¤ê
586 ·×»»¤µ¤ì¤ëÃͤò½ÐÎϤ¹¤ë¡£
587 .\"O In this system, weeks start on a Monday, and are numbered from 01,
588 .\"O for the first week, up to 52 or 53, for the last week.
589 .\"O Week 1 is the first week where four or more days fall within the
590 .\"O new year (or, synonymously, week 01 is:
591 .\"O the first week of the year that contains a Thursday;
592 .\"O or, the week that has 4 January in it).
593 ISO\ 8601 É¸½à¤Î½µÃ±°Ìɽµ­¤Ç¤Ï¡¢½µ¤Ï·îÍËÆü¤«¤é³«»Ï¤µ¤ì¡¢
594 ½µÈÖ¹æ¤Ï¡¢Ç¯¤ÎºÇ½é¤Î½µ¤¬ 01 ¤È¤Ê¤ê¡¢ºÇ¸å¤Î½µ¤Ï 52 ¤« 53 ¤È¤Ê¤ë¡£
595 ½µ 01 ¤Ï¡¢¿·¤·¤¤Ç¯¤¬ 4 Æü°Ê¾å´Þ¤Þ¤ì¤ëºÇ½é¤Î½µ¤Ç¤¢¤ë¡£
596 ¸À¤¤´¹¤¨¤ë¤È¡¢½µ 01 ¤Ï¡¢¤½¤Îǯ¤ÎÌÚÍËÆü¤ò´Þ¤àºÇ½é¤Î½µ¡¢
597 ¤Ä¤Þ¤ê 1 ·î 4 Æü¤ò´Þ¤à½µ¤È¤¤¤¦¤³¤È¤Ç¤¢¤ë¡£
598 .\"O When three of fewer days of the first calendar week of the new year fall
599 .\"O within that year,
600 .\"O then the ISO 8601 week-based system counts those days as part of week 53
601 .\"O of the preceding year.
602 ¿·¤·¤¤Ç¯¤Î¥«¥ì¥ó¥À¡¼¾å¤ÎºÇ½é¤Î½µ¤Ë¿·¤·¤¤Ç¯¤¬ 3 Æü°Ê²¼¤·¤«´Þ¤Þ¤ì¤Ê¤¤¾ì¹ç¡¢
603 ISO\ 8601 ¤Î½µÃ±°Ìɽµ­¤Ç¤Ï¡¢¤³¤ì¤é¤ÎÆü¤òÁ°¤Îǯ¤Î½µ 53 ¤Î°ìÉô¤È¤ß¤Ê¤¹¡£
604 .\"O For example, 1 January 2010 is a Friday,
605 .\"O meaning that just three days of that calendar week fall in 2010.
606 .\"O Thus, the ISO\ 8601 week-based system considers these days to be part of
607 .\"O week 53 (\fB%V\fP) of the year 2009 (\fB%G\fP) ;
608 .\"O week 01 of ISO\ 8601 year 2010 starts on Monday, 4 January 2010.
609 Î㤨¤Ð¡¢2010 Ç¯ 1 ·î 1 Æü¤Ï¶âÍËÆü¤Ç¤¢¤ê¡¢
610 ¤½¤Î½µ¤Ë¤Ï 2010 Ç¯¤ÎÆü¤¬ 3 Æü¤·¤«´Þ¤Þ¤ì¤Ê¤¤¡£
611 ¤·¤¿¤¬¤Ã¤Æ¡¢ISO\ 8601 ¤Î½µÃ±°Ìɽµ­¤Ç¤Ï¡¢¤³¤ì¤é¤ÎÆü¤Ï 2009 Ç¯ (\fB%G\fP)
612 ¤Î½µ 53 (\fB%V\fP) ¤Î°ìÉô¤È¤Ê¤ë¡£
613 ISO\ 8601 ¤Î 2010 Ç¯¤Î½µ 01 ¤Ï 2010 Ç¯ 1 ·î 4 Æü¤Î·îÍËÆü¤«¤é»Ï¤Þ¤ë¡£
614 .\"O .SS Glibc Notes
615 .SS glibc ¤Ç¤ÎÃí°Õ
616 .\"O Glibc provides some extensions for conversion specifications.
617 .\"O (These extensions are not specified in POSIX.1-2001, but a few other
618 .\"O systems provide similar features.)
619 .\"O .\" HP-UX and Tru64 also have features like this.
620 .\"O Between the \(aq%\(aq character and the conversion specifier character,
621 .\"O an optional
622 .\"O .I flag
623 .\"O and field
624 .\"O .I width
625 .\"O may be specified.
626 .\"O (These precede the
627 .\"O .B E
628 .\"O or
629 .\"O .B O
630 .\"O modifiers, if present.)
631 glibc ¤Ç¤ÏÊÑ´¹»ØÄê¤Ë¤¤¤¯¤Ä¤«³ÈÄ¥¤ò¹Ô¤Ã¤Æ¤¤¤ë
632 (¤³¤ì¤é¤Î³ÈÄ¥¤Ï POSIX.1-2001 ¤Ë¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
633 ¾¤Î¤¤¤¯¤Ä¤«¤Î¥·¥¹¥Æ¥à¤ÇƱÍͤε¡Ç½¤¬Ä󶡤µ¤ì¤Æ¤¤¤ë)¡£
634 .\" HP-UX ¤È Tru64 ¤Ë¤âƱÍͤε¡Ç½¤¬¤¢¤ë¡£
635 \(aq%\(aq Ê¸»ú¤ÈÊÑ´¹»ØÄêʸ»ú¤Î´Ö¤Ë¡¢¥ª¥×¥·¥ç¥ó¤È¤·¤Æ
636 .I flag
637 ¤È¥Õ¥£¡¼¥ë¥É¤Î
638 .I Éý
639 ¤ò»ØÄê¤Ç¤­¤ë (¤³¤ì¤é¤ò»ØÄꤹ¤ë¾ì¹ç¤Ë¤Ï
640 .B E
641 ¤ä
642 .B O
643 ½¤¾þ»Ò¤ÎÁ°¤ËÃÖ¤¯)¡£
644
645 .\"O The following flag characters are permitted:
646 °Ê²¼¤Î¥Õ¥é¥°Ê¸»ú¤¬»ÈÍѤǤ­¤ë:
647 .TP
648 .B _
649 .\"O (underscore)
650 .\"O Pad a numeric result string with spaces.
651 (²¼Àþ)
652 ¿ôÃͤηë²Ìʸ»úÎó¤Î¥Ñ¥Ç¥£¥ó¥° (·êËä¤á) ¤ò¥¹¥Ú¡¼¥¹ (¶õÇòʸ»ú) ¤Ç¹Ô¤¦¡£
653 .TP
654 .B \-
655 .\"O (dash)
656 .\"O Do not pad a numeric result string.
657 (¥À¥Ã¥·¥å)
658 ¿ôÃͤηë²Ìʸ»úÎó¤ËÂФ¹¤ë¥Ñ¥Ç¥£¥ó¥°¤ò¹Ô¤ï¤Ê¤¤¡£
659 .TP
660 .B 0
661 .\"O Pad a numeric result string with zeros even if the conversion
662 .\"O specifier character uses space-padding by default.
663 ÊÑ´¹»ØÄêʸ»ú¤¬¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¥¹¥Ú¡¼¥¹¤Ç¥Ñ¥Ç¥£¥ó¥°¤ò¹Ô¤¦¾ì¹ç¤Ç¤â¡¢
664 ¿ôÃͤηë²Ìʸ»úÎó¤Ø¤Î¥Ñ¥Ç¥£¥ó¥°¤ò 0 ¤Ç¹Ô¤¦¡£
665 .TP
666 .B ^
667 .\"O Convert alphabetic characters in result string to upper case.
668 ·ë²Ìʸ»úÎóÃæ¤Î¥¢¥ë¥Õ¥¡¥Ù¥Ã¥Èʸ»ú¤òÂçʸ»ú¤ËÊÑ´¹¤¹¤ë¡£
669 .TP
670 .B #
671 .\"O Swap the case of the result string.
672 .\"O (This flag only works with certain conversion specifier characters,
673 .\"O and of these, it is only really useful with
674 .\"O .BR %Z .)
675 ·ë²Ìʸ»úÎó¤ÎÂçʸ»ú¡¦¾®Ê¸»ú¤òÆþ¤ìÂؤ¨¤ë
676 (¤³¤Î¥Õ¥é¥°¤ÏÆÃÄê¤ÎÊÑ´¹»ØÄêʸ»ú¤Ç¤·¤«µ¡Ç½¤·¤Ê¤¤¡£¤½¤ÎÃæ¤Ç¤â
677 ËÜÅö¤ËÍ­ÍѤʤΤÏ
678 .B %Z
679 ¤Î¾ì¹ç¤À¤±¤Ç¤¢¤ë)¡£
680 .PP
681 .\"O An optional decimal width specifier may follow the (possibly absent) flag.
682 .\"O If the natural size of the field is smaller than this width,
683 .\"O then the result string is padded (on the left) to the specified width.
684 ¥ª¥×¥·¥ç¥ó¤Î10¿Ê¿ô¤ÎÉý»ØÄê»Ò¤Ï¥Õ¥é¥°¤Î¸å¤í¤ËÃÖ¤¯¤³¤È¤¬¤Ç¤­¤ë
685 (¥Õ¥é¥°¤Ï¤Ê¤¯¤Æ¤â¤è¤¤)¡£¥Õ¥£¡¼¥ë¥É¤ÎËÜÍè¤ÎÂ礭¤µ¤¬»ØÄꤵ¤ì¤¿Éý¤è¤ê¤â
686 ¾®¤µ¤¤¾ì¹ç¡¢·ë²Ìʸ»úÎó¤Îº¸Â¦¤Ï»ØÄꤵ¤ì¤¿Éý¤Þ¤Ç¥Ñ¥Ç¥£¥ó¥°¤µ¤ì¤ë¡£
687 .\"O .SH BUGS
688 .SH ¥Ð¥°
689 .\"O Some buggy versions of
690 .\"O .BR gcc (1)
691 .\"O complain about the use of
692 .\"O .BR %c :
693 .\"O .IR "warning: `%c' yields only last 2 digits of year in some locales" .
694 .BR gcc (1)
695 ¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤Ï¤ª¤«¤·¤Ê¤È¤³¤í¤¬¤¢¤ê¡¢
696 .B %c
697 ¤Î»ÈÍÑË¡¤Ë¤Ä¤¤¤Æ°Ê²¼¤Î¤è¤¦¤Ê·Ù¹ð¤ò½Ð¤¹:
698 .I "warning: `%c' yields only last 2 digits of year in some locales"
699 .RI ( ·Ù¹ð: ¤¤¤¯¤Ä¤«¤Î¥í¥±¡¼¥ë¤Ç¤Ï `%c' ¤Ïǯ¤Î²¼2·å¤·¤«½ÐÎϤ·¤Ê¤¤ )¡£
700 .\"O Of course programmers are encouraged to use
701 .\"O .BR %c ,
702 .\"O it gives the preferred date and time representation.
703 .\"O One meets all kinds of strange obfuscations
704 .\"O to circumvent this
705 .\"O .BR gcc (1)
706 .\"O problem.
707 .\"O A relatively clean one is to add an
708 .\"O intermediate function
709 ¤â¤Á¤í¤ó¥×¥í¥°¥é¥Þ¤¬
710 .B %c
711 ¤ò»È¤¦¤Î¤Ï¤ªÁ¦¤á¤Ç¤­¤ë¤³¤È¤Ç¤¢¤ë¡£
712 .B %c
713 ¤ò»È¤¦¤ÈŬÀÚ¤ÊÆüÉդȻþ¹ï¤Îɽµ­¤òÆÀ¤ë¤³¤È¤¬¤Ç¤­¤ë¤«¤é¤Ç¤¢¤ë¡£
714 .BR gcc (1)
715 ¤Î¤³¤ÎÌäÂê¤ò²óÈò¤·¤è¤¦¤È¤¹¤ë¤È¡¢²¿¤«¤¹¤Ã¤­¤ê¤·¤Ê¤¤µ¤Ê¬¤Ë¤Ê¤ë¤À¤í¤¦¡£
716 Èæ³ÓŪ¤­¤ì¤¤¤Ê²ò·èÊýË¡¤Ï°Ê²¼¤Î¤è¤¦¤ÊÃæ´Ö´Ø¿ô¤òÄɲ乤뤳¤È¤Ç¤¢¤ë¡£
717 .in +4n
718 .nf
719
720 size_t
721 my_strftime(char *s, size_t max, const char *fmt,
722             const struct tm *tm)
723 {
724     return strftime(s, max, fmt, tm);
725 }
726 .fi
727 .in
728 .RE
729
730 .\"O Nowadays,
731 .\"O .BR gcc (1)
732 .\"O provides the \fI\-Wno\-format\-y2k\fP option to prevent the warning,
733 .\"O so that the above workaround is no longer required.
734 ¸½ºß¤Ç¤Ï¡¢
735 .BR gcc (1)
736 ¤Ï¤³¤Î·Ù¹ð¤òÍÞ¤¨¤ë¤¿¤á¤Î \fI\-Wno\-format\-y2k\fP ¥ª¥×¥·¥ç¥ó¤ò
737 Ä󶡤·¤Æ¤ª¤ê¡¢¾åµ­¤Î²óÈòºö¤Ï¤â¤Ï¤äɬÍפʤ¤¡£
738 .\"O .SH EXAMPLES
739 .SH Îã
740 .\"O .BR "RFC\ 2822-compliant date format"
741 .\"O (with an English locale for %a and %b)
742 .B "RFC\ 2822 ½àµò¤ÎÆüÉÕ·Á¼°"
743 (%a ¤È %b ¤Ï±Ñ¸ì¥í¥±¡¼¥ë)
744 .PP
745 .in +2n
746 "%a,\ %d\ %b\ %Y\ %T\ %z"
747 .PP
748 .\"O .BR "RFC\ 822-compliant date format"
749 .\"O (with an English locale for %a and %b)
750 .B "RFC\ 822 ½àµò¤ÎÆüÉÕ·Á¼°"
751 (%a ¤È %b ¤Ï±Ñ¸ì¥í¥±¡¼¥ë)
752 .PP
753 .in +2n
754 "%a,\ %d\ %b\ %y\ %T\ %z"
755 .\"O .SS Example Program
756 .SS ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à
757 .\"O The program below can be used to experiment with
758 .\"O .BR strftime ().
759 °Ê²¼¤Î¥×¥í¥°¥é¥à¤ò»È¤¦¤È
760 .BR strftime ()
761 ¤Î¼Â¸³¤¬¤Ç¤­¤ë¡£
762 .PP
763 .\"O Some examples of the result string produced by the glibc implementation of
764 .\"O .BR strftime ()
765 .\"O are as follows:
766 °Ê²¼¤Ë¡¢
767 .BR strftime ()
768 ¤Î glibc ¼ÂÁõ¤¬À¸À®¤¹¤ë·ë²Ì¤ÎÎã¤ò¤¤¤¯¤Ä¤«¼¨¤¹:
769 .nf
770
771 .RB "$" " ./a.out \(aq%m\(aq"
772 Result string is "11"
773 .RB "$" " ./a.out \(aq%5m\(aq"
774 Result string is "00011"
775 .RB "$" " ./a.out \(aq%_5m\(aq"
776 Result string is "   11"
777 .fi
778 .in
779 .PP
780 .\"O Here's the program source:
781 ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹¤Ï°Ê²¼¤ÎÄ̤ê:
782 .nf
783
784 #include <time.h>
785 #include <stdio.h>
786 #include <stdlib.h>
787
788 int
789 main(int argc, char *argv[])
790 {
791     char outstr[200];
792 .PP
793 .\"O Some examples of the result string produced by the glibc implementation of
794 .\"O .BR strftime ()
795 .\"O are as follows:
796 °Ê²¼¤Ë¡¢
797 .BR strftime ()
798 ¤Î glibc ¼ÂÁõ¤¬À¸À®¤¹¤ë·ë²Ì¤ÎÎã¤ò¤¤¤¯¤Ä¤«¼¨¤¹:
799 .nf
800
801 $ ./a.out "%m"
802 Result string is "11"
803 $ ./a.out "%5m"
804 Result string is "00011"
805 $ ./a.out "%_5m"
806 Result string is "   11"
807 .fi
808     time_t t;
809     struct tm *tmp;
810
811     t = time(NULL);
812     tmp = localtime(&t);
813     if (tmp == NULL) {
814         perror("localtime");
815         exit(EXIT_FAILURE);
816     }
817
818     if (strftime(outstr, sizeof(outstr), argv[1], tmp) == 0) {
819         fprintf(stderr, "strftime returned 0");
820         exit(EXIT_FAILURE);
821     }
822
823     printf("Result string is \\"%s\\"\\n", outstr);
824     exit(EXIT_SUCCESS);
825 }
826 .fi
827 .\"O .SH "SEE ALSO"
828 .SH ´ØÏ¢¹àÌÜ
829 .BR date (1),
830 .BR time (2),
831 .BR ctime (3),
832 .BR setlocale (3),
833 .BR sprintf (3),
834 .BR strptime (3)