1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
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.
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
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 ¤Î½µÃ±°Ìɽµ
52 .TH STRFTIME 3 2010-01-17 "GNU" "Linux Programmer's Manual"
54 .\"O strftime \- format date and time
55 strftime \- ÆüÉÕ¤ª¤è¤Ó»þ¹ï¤Îʸ»úÎó¤Ø¤ÎÊÑ´¹
60 .BI "size_t strftime(char *" s ", size_t " max ", const char *" format ,
61 .BI " const struct tm *" tm );
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.
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
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)¡×¤È¸Æ¤Ð¤ì¤ëÆÃÊ̤Êʸ»úÎó¤ò
87 ³Æ¡¹¤ÎÊÑ´¹»ØÄê¤Ï \(aq%\(aq ʸ»ú¤Ç»Ï¤Þ¤ê¡¢
88 ¡ÖÊÑ´¹»ØÄêʸ»ú (conversion specifier character)¡×¤È¸Æ¤Ð¤ì¤ë
89 ²¿¤é¤«Â¾¤Îʸ»ú¤Ç½ªÃ¼¤µ¤ì¤ë¡£¾åµ°Ê³°¤ÎÁ´¤Æ¤Îʸ»úÎó¤Ï
90 ¡ÖÄ̾ï¤Îʸ»úÎó (ordinary character sequence)¡×¤È¤Ê¤ë¡£
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 °ìÊý¡¢ÊÑ´¹»ØÄê¤Îʸ»ú¤Ï°Ê²¼¤Î¤è¤¦¤ËÃÖ´¹¤µ¤ì¤ë¡£
100 .\"O The abbreviated weekday name according to the current locale.
101 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ëÍËÆü¤Î¾Êά̾¡£
104 .\"O The full weekday name according to the current locale.
105 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ëÍËÆü¤Î´°Á´¤Ê̾Á°¡£
108 .\"O The abbreviated month name according to the current locale.
109 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ë·î¤Î¾Êά̾¡£
112 .\"O The full month name according to the current locale.
113 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤±¤ë·î¤Î´°Á´¤Ê̾Á°¡£
116 .\"O The preferred date and time representation for the current locale.
117 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ë¤ª¤¤¤Æ°ìÈÌŪ¤ÊÆüÉÕ¡¦»þ¹ï¤Îɽµ¡£
120 .\"O The century number (year/100) as a 2-digit integer. (SU)
121 À¤µª (À¾Îñǯ¤Î¾å 2 ·å)¡£ (SU)
124 .\"O The day of the month as a decimal number (range 01 to 31).
125 ·îÆâÄÌ»»Æü (10 ¿Ê¿ôɽµ) (01-31)¡£
130 .\"O (Yecch\(emfor Americans only.
131 .\"O Americans should note that in other countries
133 .\"O is rather common.
134 .\"O ambiguous and should not be used.) (SU)
136 ¤ÈÅù²Á¡£(¤¦¤¨¤Ã¡¢¥¢¥á¥ê¥«ÀìÍѤÀ¡£¥¢¥á¥ê¥«°Ê³°¤Î¹ñ¤Ç¤Ï
138 ¤ÎÊý¤¬°ìÈÌŪ¤À¡£Ê¶¤é¤ï¤·¤¤¤Î¤Ç¡¢»ÈÍѤ¹¤Ù¤¤Ç¤Ï¤Ê¤¤¡£) (SU)
143 .\"O the day of the month as a decimal number, but a leading
144 .\"O zero is replaced by a space. (SU)
146 ¤ÈƱÍͤ˷îÆâÄÌ»»Æü¤ò 10 ¿Ê¿ô¤Çɽ¸½¤¹¤ë¤¬¡¢
147 1 ·å¤Î¾ì¹ç 10 ¤Î°Ì¤Ë¥¼¥í¤òÃÖ¤«¤º¥¹¥Ú¡¼¥¹¤òÃÖ¤¯¡£(SU)
150 .\"O Modifier: use alternative format, see below. (SU)
151 ÊÌ·Á¼°¤ò»ÈÍѤ¹¤ëºÝ¤Î½¤¾þ»Ò¡£²¼µ»²¾È¡£ (SU)
156 .\"O (the ISO\ 8601 date format). (C99)
158 ¤ÈÅù²Á (ISO\ 8601 ·Á¼°¤ÎÆüÉÕ¥Õ¥©¡¼¥Þ¥Ã¥È)¡£ (C99)
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
164 .\"O This has the same format and value as
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 ¿Ê¿ô¤Çɽ¤¹¡£
172 ¤ò»²¾È) ¤ËÂбþ¤·¤¿ 4 ·å¤ÎÀ¾Îñǯ¡£
175 ¤ÈƱ¤¸·Á¼°¤À¤¬¡¢ISO ½µ¿ô¤¬Á°Ç¯¤äÍâǯ¤Ë¤Ê¤ë
176 ¾ì¹ç¤Ë¤Ï¤½¤Îǯ¤¬»ÈÍѤµ¤ì¤ëÅÀ¤¬°Û¤Ê¤ë¡£(TZ)
181 .\"O but without century, that is, with a 2-digit year (00-99). (TZ)
183 ¤ÈƱÍÍ¡£Ã¢¤·¡¢À¤µª¤ò´Þ¤Þ¤º²¼ 2 ·å¤Î¤ß¤òɽ¼¨ (00-99)¡£ (TZ)
193 .\"O The hour as a decimal number using a 24-hour clock (range 00 to 23).
194 24 »þ´Öɽµ¤Ç¤Î»þ (hour)¡£ (00-23)
197 .\"O The hour as a decimal number using a 12-hour clock (range 01 to 12).
198 12 »þ´Öɽµ¤Ç¤Î»þ (hour)¡£ (01-12)
201 .\"O The day of the year as a decimal number (range 001 to 366).
202 ǯ¤Î½é¤á¤«¤éÄÌ»»¤ÎÆü¿ô¡£ (001-366)
205 .\"O The hour (24-hour clock) as a decimal number (range 0 to 23);
206 .\"O single digits are preceded by a blank.
210 24 »þ´Öɽµ¤Ç¤Î»þ (0-23)¡£
211 1 ·å¤Î¾ì¹ç¤Ë¤ÏÁ°¤Ë¥¼¥í¤Ç¤Ê¤¯¥¹¥Ú¡¼¥¹¤¬ÃÖ¤«¤ì¤ë¡£
216 .\"O The hour (12-hour clock) as a decimal number (range 1 to 12);
217 .\"O single digits are preceded by a blank.
221 12 »þ´Öɽµ¤Ç¤Î»þ (0-12)¡£
222 1 ·å¤Î¾ì¹ç¤Ë¤ÏÁ°¤Ë¥¼¥í¤Ç¤Ê¤¯¥¹¥Ú¡¼¥¹¤¬ÃÖ¤«¤ì¤ë¡£
227 .\"O The month as a decimal number (range 01 to 12).
228 ·î (10 ¿Ê¿ôɽµ)¡£ (01-12)
231 .\"O The minute as a decimal number (range 00 to 59).
232 ʬ (10 ¿Ê¿ôɽµ) (00-59)
235 .\"O A newline character. (SU)
239 .\"O Modifier: use alternative format, see below. (SU)
240 ÊÌ·Á¼°¤ò»ÈÍѤ¹¤ëºÝ¤Î½¤¾þ»Ò¡£°Ê²¼¤ò»²¾È¡£(SU)
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 Àµ¸á¤Ï¡Ö¸á¸å¡×¡¢¿¿ÌëÃæ¤Ï¡Ö¸áÁ°¡×¤È¤·¤Æ°·¤ï¤ì¤ë¡£
253 .\"O but in lowercase: "am" or "pm" or a corresponding
254 .\"O string for the current locale. (GNU)
256 ¤ÈƱÍͤǤ¢¤ë¤¬¾®Ê¸»ú¤¬»ÈÍѤµ¤ì¤ë¡£
257 ±Ñ¸ì¤Î¾ì¹ç¤Ë¤Ï "am" ¤ä "pm" ¤È¤Ê¤ë¡£(GNU)
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" .
264 ¸áÁ°¡¦¸á¸å·Á¼°¤Ç¤Î»þ¹ï¡£
270 .\"O The time in 24-hour notation (\fB%H:%M\fP). (SU)
271 .\"O For a version including the seconds, see
274 24 »þ´Öɽµ¤Ç¤Î»þ¹ï¡¢ÉäÏɽ¼¨¤·¤Ê¤¤
276 Éäò´Þ¤ó¤À¤â¤Î¤Ï°Ê²¼¤Î
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)
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 ¤Þ¤Ç¤È¤Ê¤Ã¤Æ¤¤¤ë)
291 .\"O A tab character. (SU)
295 .\"O The time in 24-hour notation (\fB%H:%M:%S\fP). (SU)
296 24 »þ´Öɽµ¤Î»þ´Ö (\fB%H:%M:%S\fP) (SU)
299 .\"O The day of the week as a decimal, range 1 to 7, Monday being 1.
303 ½µ¤Î²¿ÈÖÌܤÎÆü (10 ¿Ê¿ôɽµ) ¤«¡£·îÍËÆü¤ò 1 ¤È¤¹¤ë (1-7)¡£
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
315 ǯ¤Î½é¤á¤«¤é¤ÎÄÌ»»¤Î½µÈÖ¹æ (10 ¿Ê¿ôɽµ) (00-53)¡£
316 ¤½¤Îǯ¤ÎºÇ½é¤ÎÆüÍËÆü¤ò¡¢Âè 1 ½µ¤Î»Ï¤Þ¤ê¤È¤·¤Æ·×»»¤¹¤ë¡£
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.
331 ISO\ 8601 ·Á¼°¤Ç¤Îǯ¤Î»Ï¤á¤«¤é¤Î½µÈÖ¹æ (¡ÖÃí°Õ¡×¤ÎÀá¤ò»²¾È)¡£
332 10 ¿Ê¿ôɽµ¤Ç¡¢01 ¤«¤é 53 ¤ÎÃͤȤʤ롣½µÈÖ¹æ¤Ï¡¢
333 ¿·¤·¤¤Ç¯¤¬¾¯¤Ê¤¯¤È¤â 4 Æü°Ê¾å´Þ¤Þ¤ì¤ëºÇ½é¤Î½µ¤ò 1 ¤È¤·¤Æ·×»»¤¹¤ë¡£
340 .\"O The day of the week as a decimal, range 0 to 6, Sunday being 0.
343 ½µ¤Î²¿ÈÖÌܤÎÆü (10 ¿Ê¿ôɽµ) ¤«¡£ÆüÍËÆü¤ò 0 ¤È¤¹¤ë¡£(0-6)¡£
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 ½µ¤Î»Ï¤Þ¤ê¤È¤·¤Æ·×»»¤¹¤ë¡£
354 .\"O The preferred date representation for the current locale without the time.
355 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ç°ìÈÌŪ¤ÊÆüÉÕɽµ¡£»þ¹ï¤Ï´Þ¤Þ¤Ê¤¤¡£
358 .\"O The preferred time representation for the current locale without the date.
359 ¸½ºß¤Î¥í¥±¡¼¥ë¤Ç°ìÈÌŪ¤Ê»þ¹ïɽµ¡£ÆüÉդϴޤޤʤ¤¡£
362 .\"O The year as a decimal number without a century (range 00 to 99).
363 À¾Îñ¤Î²¼2·å (À¤µªÉôʬ¤ò´Þ¤Þ¤Ê¤¤Ç¯) (00-99)¡£
366 .\"O The year as a decimal number including the century.
367 À¤µªÉôʬ¤ò´Þ¤á¤¿ ( 4 ·å¤Î) À¾Îñǯ¡£
374 .\"O numeric timezone (that is, the hour and minute offset from UTC). (SU)
378 ¤Î·Á¼°¤Î¥¿¥¤¥à¥¾¡¼¥ó (UTC ¤Ø¤Î¥ª¥Õ¥»¥Ã¥È»þ´Ö)¡£(SU)
381 .\"O The timezone or name or abbreviation.
382 ¥¿¥¤¥à¥¾¡¼¥ó¤Þ¤¿¤Ï¥¾¡¼¥ó̾¤Þ¤¿¤Ï¾Êά̾¡£
385 .\" Nov 05 -- Not in Linux/glibc, but is in some BSDs (according to
387 .\"O The date and time in
390 .\"O (Not supported in glibc2.)
393 (glibc2 ¤Ç¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤)
396 .\"O A literal \(aq%\(aq character.
399 .\"O Some conversion specifications can be modified by preceding the
400 .\"O conversion specifier character by the
405 .\"O to indicate that an alternative format should be used.
406 ¤¤¤¯¤Ä¤«¤ÎÊÑ´¹»ØÄê¤Ç¤Ï¡¢ÊÑ´¹»ØÄêʸ»ú¤ÎÁ°¤Ë
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
436 .\"O where the effect of the
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) ¤Ç¤Ï
461 ¤Ë¤Ä¤¤¤Æµ½Ò¤¬¤¢¤ë¡£¤³¤³¤Ç
463 ½¤¾þ»Ò¤ÏÊÌ·Á¼°¤Î¿ôÃÍ (¥í¡¼¥Þ¿ô»ú¤È¤«) ¤ò»ØÄꤹ¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¡£
465 ½¤¾þ»Ò¤Ï¥í¥±¡¼¥ë°Í¸¤ÎÊÌɽ¸½¤ò»ØÄꤹ¤ë¤Î¤Ë»ÈÍѤ¹¤ë¡£
468 ½¤¾þ»Ò¤ÏÆüËܤǻÈÍѤµ¤ì¤Æ¤¤¤ë¡Ö¾¼Ï¡סÖÊ¿À®¡×
469 ¤Ê¤É¤Î¸µ¹æ¤Ë¤è¤ëǯɽµ¤ò»ØÄꤹ¤ë¡£glibc 2.2 °Ê¹ß¤Ç¤Î¤ß͸ú)
471 .\"O The broken-down time structure \fItm\fP is defined in \fI<time.h>\fP.
474 Í×ÁÇÊ̤λþ¹ï¹½Â¤ÂÎ \fItm\fP ¤Î¾ÜºÙ¤Ï \fI<time.h>\fP ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
477 .\"O .SH "RETURN VALUE"
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.
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 ¤¬ÊÖ¤µ¤ì¤ë¡£)
497 .\"O Note that the return value 0 does not necessarily indicate an error;
498 .\"O for example, in many locales
500 .\"O yields an empty string.
501 ÊÖ¤êÃÍ 0 ¤Ïɬ¤º¤·¤â¥¨¥é¡¼¤ò°ÕÌ£¤·¤Æ¤¤¤ëÌõ¤Ç¤Ï¤Ê¤¤¤Î¤ÇÃí°Õ¤¹¤ë¤³¤È¡£
502 Î㤨¤Ð¡¢Â¿¤¯¤Î¥í¥±¡¼¥ë¤Ç¤Ï
507 .\"O The environment variables
519 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï
521 ¤è¤ê¤â¤½¤Á¤é¤¬Í¥À褵¤ì¤ë¡£
525 ¤âÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï
528 .\"O .SH "CONFORMING TO"
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
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
540 .\"O several extensions that could apply to
543 ¸Ä¡¹¤ÎÊÑ´¹¤¬¸·Ì©¤Ë¤É¤Îµ¬³Ê¤Ë´Þ¤Þ¤ì¤ë¤«¤Ï¡¢
544 ANSI C (°õ¤Ê¤·)¡¢Åý°ì UNIX µ¬³Ê (SU°õ)¡¢Olson ¤Î timezone ¥Ñ¥Ã¥±¡¼¥¸ (TZ°õ)¡¢
545 glibc Æȼ« (GNU°õ) ¤Ç¼¨¤·¤Æ¤¤¤ë¡£glibc2 ¤Ç¤Ï
547 ¤Ï¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
548 ¤¤¤¯¤Ä¤«¤Î³ÈÄ¥¤¬¹Ô¤ï¤ì¤Æ¤¤¤ë¡£POSIX.1 ¤Ç¤Ï ANSI C ¤Î¤ß¤ò»²¾È¤·¤Æ¤¤¤ë¡£
551 ¤Î¤È¤³¤í¤Ëµ½Ò¤µ¤ì¤Æ¤¤¤ë´ö¤Ä¤«¤Î³ÈÄ¥¤Ï
553 ¤Ë¤âŬÍѤǤ¤ë¤À¤í¤¦¡£
556 .\"O conversion is in C99 and POSIX.1-2001.
558 ÊÑ´¹¤Ï C99 ¤È POSIX.1-2001 ¤Ë¤¢¤ë¡£
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).
568 ¤Ï 00 ¤«¤é 61 ¤ÎÈϰϤò¤È¤ë¤Èµ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
569 ¤³¤ì¤Ï¡¢1ʬ´Ö¤Î¤¦¤Á±¼Éä¬ 2¤ÄÆþ¤ë²ÄǽÀ¤¬ÍýÏÀŪ¤Ë¤Ï¤¢¤ë¤³¤È¤ò
570 ¹Íθ¤·¤Æ¤Î¤â¤Î¤Ç¤¢¤ë (¼ÂºÝ¤Ë¤Ï¡¢¤³¤Î¤è¤¦¤Ê¾õ¶·¤Ï¤³¤ì¤Þ¤Ç°ìÅÙ¤â
574 .\"O .SS ISO 8601 Week Dates
575 .SS ISO\ 8601 ¤Î½µ¡¦ÍËÆüɽµ (Week Dates)
580 .\"O yield values calculated from the week-based year defined by the
581 .\"O ISO\ 8601 standard.
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 Æü¤Î·îÍËÆü¤«¤é»Ï¤Þ¤ë¡£
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,
625 .\"O may be specified.
626 .\"O (These precede the
630 .\"O modifiers, if present.)
631 glibc ¤Ç¤ÏÊÑ´¹»ØÄê¤Ë¤¤¤¯¤Ä¤«³ÈÄ¥¤ò¹Ô¤Ã¤Æ¤¤¤ë
632 (¤³¤ì¤é¤Î³ÈÄ¥¤Ï POSIX.1-2001 ¤Ë¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¤¬¡¢
633 ¾¤Î¤¤¤¯¤Ä¤«¤Î¥·¥¹¥Æ¥à¤ÇƱÍͤε¡Ç½¤¬Ä󶡤µ¤ì¤Æ¤¤¤ë)¡£
634 .\" HP-UX ¤È Tru64 ¤Ë¤âƱÍͤε¡Ç½¤¬¤¢¤ë¡£
635 \(aq%\(aq ʸ»ú¤ÈÊÑ´¹»ØÄêʸ»ú¤Î´Ö¤Ë¡¢¥ª¥×¥·¥ç¥ó¤È¤·¤Æ
639 ¤ò»ØÄê¤Ç¤¤ë (¤³¤ì¤é¤ò»ØÄꤹ¤ë¾ì¹ç¤Ë¤Ï
645 .\"O The following flag characters are permitted:
646 °Ê²¼¤Î¥Õ¥é¥°Ê¸»ú¤¬»ÈÍѤǤ¤ë:
650 .\"O Pad a numeric result string with spaces.
652 ¿ôÃͤηë²Ìʸ»úÎó¤Î¥Ñ¥Ç¥£¥ó¥° (·êËä¤á) ¤ò¥¹¥Ú¡¼¥¹ (¶õÇòʸ»ú) ¤Ç¹Ô¤¦¡£
656 .\"O Do not pad a numeric result string.
658 ¿ôÃͤηë²Ìʸ»úÎó¤ËÂФ¹¤ë¥Ñ¥Ç¥£¥ó¥°¤ò¹Ô¤ï¤Ê¤¤¡£
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 ¤Ç¹Ô¤¦¡£
667 .\"O Convert alphabetic characters in result string to upper case.
668 ·ë²Ìʸ»úÎóÃæ¤Î¥¢¥ë¥Õ¥¡¥Ù¥Ã¥Èʸ»ú¤òÂçʸ»ú¤ËÊÑ´¹¤¹¤ë¡£
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
675 ·ë²Ìʸ»úÎó¤ÎÂçʸ»ú¡¦¾®Ê¸»ú¤òÆþ¤ìÂؤ¨¤ë
676 (¤³¤Î¥Õ¥é¥°¤ÏÆÃÄê¤ÎÊÑ´¹»ØÄêʸ»ú¤Ç¤·¤«µ¡Ç½¤·¤Ê¤¤¡£¤½¤ÎÃæ¤Ç¤â
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 ¾®¤µ¤¤¾ì¹ç¡¢·ë²Ìʸ»úÎó¤Îº¸Â¦¤Ï»ØÄꤵ¤ì¤¿Éý¤Þ¤Ç¥Ñ¥Ç¥£¥ó¥°¤µ¤ì¤ë¡£
689 .\"O Some buggy versions of
691 .\"O complain about the use of
693 .\"O .IR "warning: `%c' yields only last 2 digits of year in some locales" .
695 ¤Î¤¤¤¯¤Ä¤«¤Î¥Ð¡¼¥¸¥ç¥ó¤Ë¤Ï¤ª¤«¤·¤Ê¤È¤³¤í¤¬¤¢¤ê¡¢
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
702 .\"O it gives the preferred date and time representation.
703 .\"O One meets all kinds of strange obfuscations
704 .\"O to circumvent this
707 .\"O A relatively clean one is to add an
708 .\"O intermediate function
711 ¤ò»È¤¦¤Î¤Ï¤ªÁ¦¤á¤Ç¤¤ë¤³¤È¤Ç¤¢¤ë¡£
713 ¤ò»È¤¦¤ÈŬÀÚ¤ÊÆüÉդȻþ¹ï¤Îɽµ¤òÆÀ¤ë¤³¤È¤¬¤Ç¤¤ë¤«¤é¤Ç¤¢¤ë¡£
715 ¤Î¤³¤ÎÌäÂê¤ò²óÈò¤·¤è¤¦¤È¤¹¤ë¤È¡¢²¿¤«¤¹¤Ã¤¤ê¤·¤Ê¤¤µ¤Ê¬¤Ë¤Ê¤ë¤À¤í¤¦¡£
716 Èæ³ÓŪ¤¤ì¤¤¤Ê²ò·èÊýË¡¤Ï°Ê²¼¤Î¤è¤¦¤ÊÃæ´Ö´Ø¿ô¤òÄɲ乤뤳¤È¤Ç¤¢¤ë¡£
721 my_strftime(char *s, size_t max, const char *fmt,
724 return strftime(s, max, fmt, tm);
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.
736 ¤Ï¤³¤Î·Ù¹ð¤òÍÞ¤¨¤ë¤¿¤á¤Î \fI\-Wno\-format\-y2k\fP ¥ª¥×¥·¥ç¥ó¤ò
737 Ä󶡤·¤Æ¤ª¤ê¡¢¾åµ¤Î²óÈòºö¤Ï¤â¤Ï¤äɬÍפʤ¤¡£
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 ¤Ï±Ñ¸ì¥í¥±¡¼¥ë)
746 "%a,\ %d\ %b\ %Y\ %T\ %z"
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 ¤Ï±Ñ¸ì¥í¥±¡¼¥ë)
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 °Ê²¼¤Î¥×¥í¥°¥é¥à¤ò»È¤¦¤È
763 .\"O Some examples of the result string produced by the glibc implementation of
768 ¤Î glibc ¼ÂÁõ¤¬À¸À®¤¹¤ë·ë²Ì¤ÎÎã¤ò¤¤¤¯¤Ä¤«¼¨¤¹:
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"
780 .\"O Here's the program source:
781 ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹¤Ï°Ê²¼¤ÎÄ̤ê:
789 main(int argc, char *argv[])
793 .\"O Some examples of the result string produced by the glibc implementation of
798 ¤Î glibc ¼ÂÁõ¤¬À¸À®¤¹¤ë·ë²Ì¤ÎÎã¤ò¤¤¤¯¤Ä¤«¼¨¤¹:
802 Result string is "11"
804 Result string is "00011"
806 Result string is " 11"
818 if (strftime(outstr, sizeof(outstr), argv[1], tmp) == 0) {
819 fprintf(stderr, "strftime returned 0");
823 printf("Result string is \\"%s\\"\\n", outstr);