OSDN Git Service

(split) LDP v3.30, v3.31 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / release / man3 / getdate.3
1 .\" Copyright 2001 walter harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" Modified, 2001-12-26, aeb
26 .\" 2008-09-07, mtk, Various rewrites; added an example program.
27 .\"
28 .\" Japanese Version Copyright (c) 2002 NAKANO Takeo
29 .\" and Copyright (c) 2008, Akihiro MOTOKI all rights reserved.
30 .\"
31 .\" Translated 2002-01-12, NAKANO Takeo <nakano@apm.seikei.ac.jp>
32 .\" Updated 2008-09-20, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.09
33 .\"
34 .\"WORD:        broken-down time        Í×ÁÇÊ̤λþ¹ï
35 .\"
36 .TH GETDATE 3 2010-09-20 "" "Linux Programmer's Manual"
37 .SH Ì¾Á°
38 getdate, getdate_r \- ÆüÉդȻþ¹ï¤Îʸ»úÎó¤òÍ×ÁÇÊ̤λþ¹ï¤ËÊÑ´¹¤¹¤ë
39 .SH ½ñ¼°
40 .B "#include <time.h>"
41 .sp
42 .BI "struct tm *getdate(const char *" string );
43 .sp
44 .B "extern int getdate_err;"
45 .sp
46 .B "#include <time.h>"
47 .sp
48 .BI "int getdate_r(const char *" string ", struct tm *" res );
49 .sp
50 .in -4n
51 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
52 .RB ( feature_test_macros (7)
53 »²¾È):
54 .in
55 .sp
56 .BR getdate ():
57 .ad l
58 .RS 4
59 _XOPEN_SOURCE\ >=\ 500 ||
60 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
61 .RE
62 .br
63 .BR getdate_r ():
64 .ad l
65 .RS 4
66 _GNU_SOURCE
67 .RE
68 .ad
69 .SH ÀâÌÀ
70 .BR getdate ()
71 ´Ø¿ô¤Ï¡¢
72 .I string
73 ¤¬»Ø¤¹¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤¿Ê¸»úÎóɽ¸½¤ÎÆüÉդȻþ¹ï¤ò¡¢
74 Í×ÁÇÊ̤λþ¹ï (broken-down time) ¤ËÊÑ´¹¤¹¤ë¡£
75 Í×ÁÇÊ̤λþ¹ï¤Ï
76 .I tm
77 ¹½Â¤ÂΤ˳ÊǼ¤µ¤ì¡¢¤³¤Î¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤¬´Ø¿ô¤Î·ë²Ì¤È¤·¤ÆÊÖ¤µ¤ì¤ë¡£
78 ¤³¤Î
79 .I tm
80 ¹½Â¤ÂΤÏÀÅŪ¤Ê¥á¥â¥êÎΰè¤Ë¤¢¤ê¡¢
81 .BR getdate ()
82 ¤Î¤½¤ì°Ê¹ß¤Î¸Æ¤Ó½Ð¤·¤Ç¾å½ñ¤­¤µ¤ì¤ë¤«¤â¤µ¤ì¤Ê¤¤¡£
83 .PP
84 .RI ( format
85 °ú¤­¿ô¤Ç¥Õ¥©¡¼¥Þ¥Ã¥È¤ò»ØÄꤹ¤ë)
86 .BR strptime (3)
87 ¤È¤Ï°ã¤¤¡¢
88 .BR getdate ()
89 ¤Ï´Ä¶­ÊÑ¿ô
90 .B DATEMSK
91 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥ë¥Ñ¥¹Ì¾¤Î¥Õ¥¡¥¤¥ë¤Ë½ñ¤¤¤Æ¤¢¤ë¥Õ¥©¡¼¥Þ¥Ã¥È¤òÍѤ¤¤ë¡£
92 .PP
93 ¥Þ¥Ã¥Á¤ÎºÝ¤Ë¤ÏÂçʸ»ú¾®Ê¸»ú¤ò¶èÊ̤·¤Ê¤¤¡£
94 ¥Ñ¥¿¡¼¥óÃæ¤Ç¤âÊÑ´¹¤µ¤ì¤ëʸ»úÎóÃæ¤Ç¤â¡¢Í¾Ê¬¤Ê¶õÇòʸ»ú¤Ï̵»ë¤µ¤ì¤ë¡£
95 .PP
96 ¥Ñ¥¿¡¼¥ó¤Ë»ØÄê¤Ç¤­¤ëÊÑ´¹»ØÄê¤Ï¡¢
97 .BR strptime (3)
98 ¤Î¤â¤Î¤ÈƱ¤¸¤Ç¤¢¤ë¡£
99 POSIX.1-2001 ¤Ç¤Ï°ì¤Ä¤ÎÊÑ´¹»ØÄ꤬Äɲäǵ¬Äꤵ¤ì¤Æ¤¤¤ë¡£
100 .TP
101 .B %Z
102 ¥¿¥¤¥à¥¾¡¼¥ó¤Î̾Á°¡£
103 glibc ¤Ç¤Ï¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
104 .LP
105 .B %Z
106 ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢Í×ÁÇÊ̤λþ¹ï¤ò³ÊǼ¤¹¤ë¹½Â¤ÂΤϡ¢
107 »ØÄꤵ¤ì¤¿¥¿¥¤¥à¥¾¡¼¥ó¤Ë¤ª¤±¤ë¸½ºß»þ¹ï¤ËÂбþ¤¹¤ëÃͤǽé´ü²½¤µ¤ì¤ë¡£
108 »ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¤³¤Î¹½Â¤ÂΤϸ½ºß¤Î¥í¡¼¥«¥ë¥¿¥¤¥à¤ËÂбþ¤¹¤ë
109 Í×ÁÇÊ̤λþ¹ï¤Ç½é´ü²½¤µ¤ì¤ë
110 .RB ( localtime (3)
111 ¤ò¸Æ¤Ó½Ð¤·¤¿¾ì¹ç¤ÈƱ¤¸)¡£
112 .LP
113 ÍËÆü¤À¤±¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
114 º£Æü¤Þ¤¿¤Ïº£Æü°Ê¹ß¤Ç¡¢
115 ¤½¤ÎÍËÆü¤Ë¹çÃפ¹¤ëºÇ½é¤ÎÆü¤¬ºÎÍѤµ¤ì¤ë¡£
116 .LP
117 (ǯ¤Ê¤·¤Ç) ·î¤À¤±¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
118 º£·î¤Þ¤¿¤Ïº£·î°Ê¹ß¤Ç¡¢
119 ¤½¤Î·î¤Ë¹çÃפ¹¤ëºÇ½é¤Î·î¤¬ºÎÍѤµ¤ì¤ë¡£
120 .LP
121 »þ¡¦Ê¬¡¦É䬤¤¤º¤ì¤â»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¡¢
122 ¸½ºß¤Î»þ¡¦Ê¬¡¦É䬺ÎÍѤµ¤ì¤ë¡£
123 .LP
124 ÆüÉդλØÄ꤬¤Ê¤«¤Ã¤¿¤¬¡¢»þ´Ö (hour) ¤À¤±»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
125 ¸½ºß¤Î»þ´Ö¤Þ¤¿¤Ï¤½¤ì°Ê¹ß¤Ç¡¢¤½¤Î»ØÄê¤Ë¹çÃפ¹¤ëºÇ½é¤Î»þ´Ö¤¬ºÎÍѤµ¤ì¤ë¡£
126
127 .BR getdate_r ()
128 ¤Ï GNU ³ÈÄ¥¤Ç
129 .BR getdate ()
130 ¤Î¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤòÄ󶡤·¤Æ¤¤¤ë¡£
131 .BR getdate_r ()
132 ¤Ç¤Ï¡¢¥¨¥é¡¼¤òÊó¹ð¤¹¤ë¤Î¤Ë¥°¥í¡¼¥Ð¥ëÊÑ¿ô¤ò»ÈÍѤ·¤¿¤ê¡¢
133 Í×ÁÇÊ̤λþ¹ï¤òÊÖ¤¹¤Î¤ËÀÅŪ¤Ê¥Ð¥Ã¥Õ¥¡¤ò»ÈÍѤ·¤¿¤ê¤»¤º¡¢
134 ¥¨¥é¡¼¤ò´Ø¿ô¤ÎÊÖ¤êÃÍ·Ðͳ¤ÇÊó¹ð¤·¡¢Í×ÁÇÊ̤λþ¹ï¤ò
135 °ú¤­¿ô
136 .I res
137 ¤¬»Ø¤·¼¨¤¹¸Æ¤Ó½Ð¤·Â¦¤Ç³ä¤êÅö¤Æ¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤·¤ÆÊÖ¤¹¡£
138 .SH ÊÖ¤êÃÍ
139 À®¸ù¤¹¤ë¤È¡¢
140 .BR getdate ()
141 ¤Ï
142 .I struct tm
143 ¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¡£
144 ¼ºÇÔ¤¹¤ë¤È NULL ¤òÊÖ¤·¡¢¥°¥í¡¼¥Ð¥ëÊÑ¿ô
145 .I getdate_err
146 ¤Ë°Ê²¼¤Ë¼¨¤¹¥¨¥é¡¼ÈÖ¹æ¤Î¤¤¤º¤ì¤«°ì¤Ä¤òÀßÄꤹ¤ë¡£
147 .I errno
148 ¤ÎÊѹ¹¤Ë¤Ä¤¤¤Æ¤Ïµ¬Äꤵ¤ì¤Æ¤¤¤Ê¤¤¡£
149
150 À®¸ù¤¹¤ë¤È¡¢
151 .BR getdate_r ()
152 ¤Ï 0 ¤òÊÖ¤¹¡£
153 ¼ºÇÔ¤¹¤ë¤È¡¢°Ê²¼¤Ë¼¨¤¹¥¨¥é¡¼ÈÖ¹æ¤Î¤¤¤º¤ì¤«°ì¤Ä¤òÊÖ¤¹¡£
154 .SH ¥¨¥é¡¼
155 °Ê²¼¤Î¥¨¥é¡¼¤¬¡¢
156 .RB ( getdate ()
157 ¤Ç¤Ï)
158 .I getdate_err
159 ·Ðͳ¤ÇÊÖ¤µ¤ì¡¢
160 .RB ( getdate_r ()
161 ¤Ç¤Ï) ´Ø¿ô¤ÎÊÖ¤êÃͤȤ·¤ÆÊÖ¤µ¤ì¤ë¡£
162 .TP 4n
163 .B 1
164 ´Ä¶­ÊÑ¿ô
165 .B DATEMASK
166 ¤¬Ì¤ÄêµÁ¡¢¤Þ¤¿¤Ï¤½¤ÎÃͤ¬¶õʸ»úÎó¤Ç¤¢¤ë¡£
167 .TP
168 .B 2
169 .B DATEMSK
170 ¤Ç»ØÄꤵ¤ì¤¿¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤òÆɤ߹þ¤ßÍѤ˥ª¡¼¥×¥ó¤Ç¤­¤Ê¤¤¡£
171 .TP
172 .B 3
173 ¥Õ¥¡¥¤¥ë¤Î¥¹¥Æ¡¼¥¿¥¹¾ðÊ󤬼èÆÀ¤Ç¤­¤Ê¤¤¡£
174 .\" stat()
175 .TP
176 .B 4
177 ¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤¬Ä̾ï¤Î¥Õ¥¡¥¤¥ë¤Ç¤Ê¤¤¡£
178 .TP
179 .B 5
180 ¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ßÃæ¤Ë¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¡£
181 .TP
182 .B 6
183 ¥á¥â¥ê¤Î³ä¤êÅö¤Æ¤Ë¼ºÇÔ¤·¤¿ (¥á¥â¥ê¤¬Â­¤ê¤Ê¤¤)¡£
184 .\" ¥¨¥é¡¼ 6 ¤Ï glibc ¤Ç¤ÏȯÀ¸¤·¤Ê¤¤¤è¤¦¤Ë¸«¤¨¤ë¡£
185 .TP
186 .B 7
187 ÆþÎϤ˥ޥåÁ¤·¤¿¥Õ¥¡¥¤¥ë¤Ë¡¢¹Ô¤¬´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
188 .TP
189 .B 8
190 ÆþÎÏ»ØÄ꤬Àµ¤·¤¯¤Ê¤¤¡£
191 .SH ´Ä¶­ÊÑ¿ô
192 .TP
193 .B DATEMSK
194 ½ñ¼°¥Ñ¥¿¡¼¥ó¤ò´Þ¤à¥Õ¥¡¥¤¥ë¡£
195 .TP
196 .BR TZ ", " LC_TIME
197 .BR strptime (3)
198 ¤¬ÍѤ¤¤ëÊÑ¿ô¡£
199 .SH ½àµò
200 POSIX.1-2001.
201 .SH Ãí°Õ
202 POSIX.1-2001 »ÅÍͤǤϡ¢
203 .BR strptime (3)
204 ¤Ë¤Ä¤¤¤Æ¤Ï
205 .B %E
206 ¤ä
207 .B %O
208 ¤È¤¤¤Ã¤¿½¤Àµ»Ò¤òÍѤ¤¤¿ÊÑ´¹»ØÄê¤òµ¬Äꤷ¤Æ¤¤¤ë¤¬¡¢
209 .BR getdate ()
210 ¤Ë¤Ä¤¤¤Æ¤Ï¤³¤Î¤è¤¦¤Ê½¤¾þ»Ò¤Îµ¬Äê¤Ï¤Ê¤¤¡£
211 glibc ¤Ç¤Ï¡¢
212 .BR getdate ()
213 ¤Ï
214 .BR strptime (3)
215 ¤òÍѤ¤¤Æ¼ÂÁõ¤µ¤ì¤Æ¤ª¤ê¡¢
216 ξ¼Ô¤Ç¤ÏÁ´¤¯Æ±¤¸ÊÑ´¹¤¬Î¾¼Ô¤Ç¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£
217 .SH Îã
218 °Ê²¼¤Î¥×¥í¥°¥é¥à¤Ï¡¢¥³¥Þ¥ó¥É¥é¥¤¥ó°ú¤­¿ô¤Î¤½¤ì¤¾¤ì¤Ë¤Ä¤¤¤Æ
219 .BR getdate ()
220 ¤ò¸Æ¤Ó½Ð¤·¡¢¤½¤ì¤¾¤ì¤Ë¤Ä¤¤¤ÆÊÖ¤µ¤ì¤¿
221 .I tm
222 ¹½Â¤ÂΤΥե£¡¼¥ë¥ÉÃͤòɽ¼¨¤¹¤ë¡£
223 ¼¡¤Î¥·¥§¥ë¡¦¥»¥Ã¥·¥ç¥ó¤Ï¡¢¥×¥í¥°¥é¥à¤ÎÆ°ºîÎã¤Ç¤¢¤ë¡£
224
225 .in +4n
226 .nf
227 .RB "$" " TFILE=$PWD/tfile"
228 .RB "$" " echo \(aq%A\(aq > $TFILE " "      # Full weekday name"
229 .RB "$" " echo \(aq%T\(aq >> $TFILE" "      # ISO date (YYYY-MM-DD)"
230 .RB "$" " echo \(aq%F\(aq >> $TFILE" "      # Time (HH:MM:SS)"
231 .RB "$" " date"
232 .RB "$" " export DATEMSK=$TFILE"
233 .RB "$" " ./a.out Tuesday \(aq2009-12-28\(aq \(aq12:22:33\(aq"
234 Sun Sep  7 06:03:36 CEST 2008
235 Call 1 ("Tuesday") succeeded:
236     tm_sec   = 36
237     tm_min   = 3
238     tm_hour  = 6
239     tm_mday  = 9
240     tm_mon   = 8
241     tm_year  = 108
242     tm_wday  = 2
243     tm_yday  = 252
244     tm_isdst = 1
245 Call 2 ("2009-12-28") succeeded:
246     tm_sec   = 36
247     tm_min   = 3
248     tm_hour  = 6
249     tm_mday  = 28
250     tm_mon   = 11
251     tm_year  = 109
252     tm_wday  = 1
253     tm_yday  = 361
254     tm_isdst = 0
255 Call 3 ("12:22:33") succeeded:
256     tm_sec   = 33
257     tm_min   = 22
258     tm_hour  = 12
259     tm_mday  = 7
260     tm_mon   = 8
261     tm_year  = 108
262     tm_wday  = 0
263     tm_yday  = 250
264     tm_isdst = 1
265 .fi
266 .in
267 .SS ¥×¥í¥°¥é¥à¤Î¥½¡¼¥¹
268 \&
269 .nf
270 #define _GNU_SOURCE 500
271 #include <time.h>
272 #include <stdio.h>
273 #include <stdlib.h>
274
275 int
276 main(int argc, char *argv[])
277 {
278     struct tm *tmp;
279     int j;
280
281     for (j = 1; j < argc; j++) {
282         tmp = getdate(argv[j]);
283
284         if (tmp == NULL) {
285             printf("Call %d failed; getdate_err = %d\\n",
286                    j, getdate_err);
287             continue;
288         }
289
290         printf("Call %d (\\"%s\\") succeeded:\\n", j, argv[j]);
291         printf("    tm_sec   = %d\\n", tmp\->tm_sec);
292         printf("    tm_min   = %d\\n", tmp\->tm_min);
293         printf("    tm_hour  = %d\\n", tmp\->tm_hour);
294         printf("    tm_mday  = %d\\n", tmp\->tm_mday);
295         printf("    tm_mon   = %d\\n", tmp\->tm_mon);
296         printf("    tm_year  = %d\\n", tmp\->tm_year);
297         printf("    tm_wday  = %d\\n", tmp\->tm_wday);
298         printf("    tm_yday  = %d\\n", tmp\->tm_yday);
299         printf("    tm_isdst = %d\\n", tmp\->tm_isdst);
300     }
301
302     exit(EXIT_SUCCESS);
303 }
304 .fi
305 .SH ´ØÏ¢¹àÌÜ
306 .BR time (2),
307 .BR localtime (3),
308 .BR setlocale (3),
309 .BR strftime (3),
310 .BR strptime (3)