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 .\" Modified Sat Jul 24 19:49:27 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Modified Fri Apr 26 12:38:55 MET DST 1996 by Martin Schulze (joey@linux.de)
29 .\" Modified 2001-11-13, aeb
30 .\" Modified 2004-11-16, mtk
32 .\" Japanese Version Copyright (c) 1997 Hiroaki Nagoya
33 .\" all rights reserved.
34 .\" Translated 1997-02-10, Hiroaki Nagoya <nagoya@is.titech.ac.jp>
35 .\" Updated 1999-09-01, Kentaro Shirakata <argrath@ub32.org>
36 .\" Updated 2001-10-15, Kentaro Shirakata <argrath@ub32.org>
37 .\" Updated 2001-12-13, Kentaro Shirakata <argrath@ub32.org>
38 .\" Updated 2002-01-03, Kentaro Shirakata <argrath@ub32.org>
39 .\" Updated 2005-02-24, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
40 .\" Updated 2008-04-04, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.79
41 .\" Updated 2008-08-08, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.05
42 .\" Updated 2008-11-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.13
44 .\"WORD: Coordinated Univarsal Time ¶¨ÄêÀ¤³¦»þ
45 .\"WORD: broken-down time Í×ÁÇÊ̤λþ¹ï
47 .TH CTIME 3 2010-02-25 "" "Linux Programmer's Manual"
49 asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r,
50 localtime_r \- ÆüÉդȻþ¹ï¤òÍ×ÁÇÊ̤λþ¹ï¤ä ASCII ¤ËÊÑ´¹¤¹¤ë
55 .BI "char *asctime(const struct tm *" tm );
57 .BI "char *asctime_r(const struct tm *" tm ", char *" buf );
59 .BI "char *ctime(const time_t *" timep );
61 .BI "char *ctime_r(const time_t *" timep ", char *" buf );
63 .BI "struct tm *gmtime(const time_t *" timep );
65 .BI "struct tm *gmtime_r(const time_t *" timep ", struct tm *" result );
67 .BI "struct tm *localtime(const time_t *" timep );
69 .BI "struct tm *localtime_r(const time_t *" timep ", struct tm *" result );
71 .BI "time_t mktime(struct tm *" tm );
75 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
76 .RB ( feature_test_macros (7)
86 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
87 _SVID_SOURCE || _POSIX_SOURCE
96 \fItime_t\fP ·¿¤Î¥«¥ì¥ó¥À¡¼»þ¹ï¤ò°ú¤¿ô¤Ë¤È¤ë¡£
97 °ú¤¿ô¤¬ÀäÂÐÃͤȤ·¤Æ²ò¼á¤µ¤ì¤ë¾ì¹ç¤Ï¡¢»þ¹ïµª¸µ (Epoch;
98 1970-01-01 00:00:00 +0000 (UTC)) ¤«¤é¤Î·Ð²áÉÿô¤È²ò¼á¤µ¤ì¤ë¡£
105 ǯ¡¦·î¡¦Æü¤Ê¤É¤ËʬΥ¤µ¤ì¤¿Í×ÁÇÊ̤λþ¹ï¤ò°ú¤¿ô¤È¤¹¤ë¡£
107 Í×ÁÇÊ̤λþ¹ï¤Ï \fI<time.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë
108 \fItm\fP ¹½Â¤ÂΤËÊÝ»ý¤µ¤ì¤ë¡£
115 int tm_hour; /* »þ´Ö */
116 int tm_mday; /* Æü */
119 int tm_wday; /* ÍËÆü */
120 int tm_yday; /* ǯÆâÄÌ»»Æü */
121 int tm_isdst; /* ²Æ»þ´Ö */
126 \fItm\fP ¹½Â¤ÂΤΥá¥ó¥Ð¡¼¤Ï°Ê²¼¤ÎÄ̤ê:
129 Éÿô¡¢¤Õ¤Ä¤¦¤Ï 0 ¤«¤é 59 ¤Þ¤Ç¤ÎÃÍ¡¢
130 ¤·¤«¤·±¼ÉäΤ¿¤á 60 ¤Þ¤Ç¤ÎÃͤϵö¤µ¤ì¤ë¡£
133 ʬ¿ô¡¢0 ¤«¤é 59 ¤Þ¤Ç¤ÎÃÍ¡£
136 ¿¿ÌëÃ椫¤é¤ÎÄÌ»»»þ´Ö¡¢0 ¤«¤é 23 ¤Þ¤Ç¤ÎÃÍ¡£
139 ·î¤Ï¤¸¤á¤«¤é¤ÎÆü¿ô¡¢1 ¤«¤é 31 ¤Þ¤Ç¤ÎÃÍ¡£
142 1·î¤«¤é¤ÎÄÌ»»·î¿ô¡¢0 ¤«¤é 11 ¤Þ¤Ç¤ÎÃÍ¡£
145 1900 ǯ¤«¤é¤ÎÄÌ»»Ç¯¿ô¡£
148 ÆüÍËÆü¤«¤é¤ÎÄÌ»»Æü¿ô(ÍËÆü)¡£0 ¤«¤é 6 ¤Þ¤Ç¤ÎÃÍ¡£
151 1 ·î 1 Æü¤«¤é¤ÎÄÌ»»Æü¿ô¡¢0 ¤«¤é 365 ¤Þ¤Ç¤ÎÃÍ¡£
154 ²Æ»þ´Ö¤¬Í¸ú¤«¤É¤¦¤«¤Î¥Õ¥é¥°¡£
155 Àµ¤ÎÃͤʤé¤Ð²Æ»þ´Ö¤Ï͸ú¤Ë¤Ê¤ê¡¢0 ¤Ê¤é¤Ð̵¸ú¡¢Éé¤ÎÃͤʤé¤Ð¤³¤Î¾ðÊó¤Ë¤Ï
160 .BI asctime(localtime( t ))
162 ¥«¥ì¥ó¥À¡¼»þ¹ï \fIt\fP ¤ò
165 "Wed Jun 30 21:49:08 1993\\n"
168 ¤È¤¤¤¦·Á¼°¤Î NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤ØÊÑ´¹¤¹¤ë¡£
170 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ¤Ç¤¢¤ë¡£
171 ·î¤Îά¾Î¤Ï "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
172 "Sep", "Oct", "Nov", "Dec" ¤Ç¤¢¤ë¡£
173 ÊÖ¤êÃͤϡ¢ÀÅŪ (static) ¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
174 ¤³¤Îʸ»úÎó¤Ï¡¢ÆüÉÕ¡¦»þ¹ï´Ø¿ô¤Î¤¤¤º¤ì¤«¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¾å½ñ¤¤µ¤ì¤ë¤³¤È¤¬¤¢¤ë¡£
175 ¤Þ¤¿¤³¤Î´Ø¿ô¤ÏÂç°èÊÑ¿ô \fItzname\fP, \fItimezone\fP, \fIdaylight\fP
176 ¤Ë¸½ºß¤Î¥¿¥¤¥à¥¾¡¼¥ó¤Î¾ðÊó¤òÀßÄꤹ¤ë
179 ¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤǤ¢¤ë
182 ʸ»úÎó¤Ï¥æ¡¼¥¶¡¼¤¬ÍÑ°Õ¤·¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º¤Ï
183 ¾¯¤Ê¤¯¤È¤â 26 ¥Ð¥¤¥È°Ê¾å¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
184 ¤³¤Î´Ø¿ô¤Ï \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP
185 ¤òÀßÄꤹ¤ëɬÍפϤʤ¤¡£
189 ¤Ï¡¢¥«¥ì¥ó¥À¡¼»þ¹ï \fItimep\fP ¤ò
190 ¶¨ÄêÀ¤³¦»þ (UTC) ¤Ç¤ÎÍ×ÁÇÊ̤λþ¹ï¤ØÊÑ´¹¤¹¤ë¡£
191 ǯ¤¬À°¿ô·¿¤Ë¼ý¤Þ¤é¤Ê¤¤¾ì¹ç¡¢NULL ¤òÊÖ¤¹¡£
192 ÊÖ¤êÃͤÏÀÅŪ¤Ë³ÎÊݤµ¤ì¤¿¹½Â¤ÂΤò»Ø¤·¤Æ¤ª¤ê¡¢¤³¤Î¸å¤Ç
193 ÆüÉÕ¤ä»þ¹ï¤Ë´Ø¤¹¤ë´Ø¿ô¤Î¤¤¤º¤ì¤«¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È
194 ¾å½ñ¤¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
197 ¥Ç¡¼¥¿¤Ï¥æ¡¼¥¶¡¼¤¬ÍÑ°Õ¤·¤¿¹½Â¤ÂΤ˳ÊǼ¤µ¤ì¤ë¡£
201 ¤Ï¡¢¥«¥ì¥ó¥À¡¼»þ¹ï \fItimep\fP ¤ò
202 ¥æ¡¼¥¶¤¬»ØÄꤷ¤¿¥¿¥¤¥à¥¾¡¼¥ó¤Ç¤Î»þ¹ïÍ×ÁÇÊ̤Îɽ¸½¤ØÊÑ´¹¤¹¤ë¡£
205 ¤ò¸Æ¤Ó½Ð¤·¤¿¤«¤Î¤è¤¦¤Ë¿¶Éñ¤¤¡¢
206 Âç°èÊÑ¿ô \fItzname\fP ¤Ë¸½ºß¤Î¥¿¥¤¥à¥¾¡¼¥ó¤Î¾ðÊó¤òÀßÄꤹ¤ë¡£
207 ¤Þ¤¿¡¢\fItimezone\fP ¤Ë¶¨ÄêÀ¤³¦»þ (UTC) ¤È¥í¡¼¥«¥ëɸ½à»þ¤È¤Î
209 °ìǯ¤Î°ìÉô¤Ç²Æ»þ´Ö¤¬Å¬ÍѤµ¤ì¤ë¾ì¹ç¤Ï \fIdaylight\fP ¤Ë 0 ¤¬ÀßÄꤵ¤ì¤ë¡£
210 ÊÖ¤êÃͤÏÀÅŪ¤Ë³ÎÊݤµ¤ì¤¿¹½Â¤ÂΤò»Ø¤·¤Æ¤ª¤ê¡¢¤³¤Î¸å¤Ç
211 ÆüÉÕ¤ä»þ¹ï¤Ë´Ø¤¹¤ë´Ø¿ô¤Î¤¤¤º¤ì¤«¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È
212 ¾å½ñ¤¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
215 ¥Ç¡¼¥¿¤Ï¥æ¡¼¥¶¡¼¤¬ÍÑ°Õ¤·¤¿¹½Â¤ÂΤ˳ÊǼ¤µ¤ì¤ë¡£
216 ¤³¤Î´Ø¿ô¤Ï \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP
217 ¤òÀßÄꤹ¤ëɬÍפϤʤ¤¡£
221 ¤Ï¡¢Í×ÁÇÊ̤λþ¹ï \fItm\fP ¤ò
223 ¤ÈƱ¤¸·Á¼°¤Î NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤ØÊÑ´¹¤¹¤ë¡£
224 ÊÖ¤êÃͤÏÀÅŪ¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£¤³¤Îʸ»úÎó¤Ï¡¢
225 ÆüÉÕ¡¦»þ¹ï´Ø¿ô¤Î¤¤¤º¤ì¤«¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¾å½ñ¤¤µ¤ì¤ë¤³¤È¤¬¤¢¤ë¡£
226 ¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤǤ¢¤ë
229 ʸ»úÎó¤Ï¥æ¡¼¥¶¡¼¤¬ÍÑ°Õ¤·¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º¤Ï
230 ¾¯¤Ê¤¯¤È¤â 26 ¥Ð¥¤¥È°Ê¾å¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
234 ¤Ï¡¢(¥í¡¼¥«¥ë¥¿¥¤¥à¤Çµ½Ò¤µ¤ì¤Æ¤¤¤ë) Í×ÁÇÊ̤λþ¹ï¤ò
235 ¥«¥ì¥ó¥À¡¼»þ¹ï¤ØÊÑ´¹¤¹¤ë¡£¤³¤ÎºÝ¡¢¸Æ¤Ó½Ð¤·¸µ¤¬¥Õ¥£¡¼¥ë¥É
239 ¤Ç»ØÄꤷ¤¿ÃͤÏ̵»ë¤µ¤ì¤ë¡£
243 ¤Ç»ØÄꤵ¤ì¤¿Ãͤˤè¤ê¡¢
245 ¹½Â¤ÂΤÇÅϤµ¤ì¤¿»þ¹ï¤Ç²Æ»þ´Ö (daylight saving time; DST) ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ
247 Àµ¤ÎÃͤϲƻþ´Ö¤¬Í¸ú¤Ç¤¢¤ë¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
250 ¤Ï (¥¿¥¤¥à¥¾¡¼¥ó¾ðÊó¤È¥·¥¹¥Æ¥à¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò»È¤Ã¤Æ)
251 »ØÄꤵ¤ì¤¿»þ¹ï¤Ç²Æ»þ´Ö¤¬Í¸ú¤«¤É¤¦¤«¤òȽÃǤ¹¤ëɬÍפ¬¤¢¤ë¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
256 ¹½Â¤ÂΤγƥե£¡¼¥ë¥É¤ò°Ê²¼¤Î¤è¤¦¤Ë½¤Àµ¤¹¤ë¡£
260 ¤Ë¤Ï¾¤Î¥Õ¥£¡¼¥ë¥É¤ÎÆâÍƤ«¤éµá¤á¤¿ÃͤòÀßÄꤹ¤ë¡£
261 ¹½Â¤ÂΤÎÍ×ÁǤ¬Í¸ú¤ÊÈϰϤˤʤ¤¾ì¹ç¡¢Àµµ¬²½¤µ¤ì¤ë
262 (Î㤨¤Ð¡¢10 ·î 40 Æü¤Ï 11 ·î 9 Æü¤ËÊѹ¹¤µ¤ì¤ë)¡£
264 ¤Ë¤Ï (ºÇ½é¤ÎÃͤˤ«¤«¤ï¤é¤º) Àµ¤ÎÃͤ« 0 ¤¬ÀßÄꤵ¤ì¤ë¡£
265 Àµ¤ÎÃͤϻØÄꤵ¤ì¤¿»þ´Ö¤Ç²Æ»þ´Ö¤¬Í¸ú¤Ç¤¢¤ë¤³¤È¤ò¼¨¤·¡¢
266 0 ¤Ï̵¸ú¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
270 Âç°èÊÑ¿ô \fItzname\fP ¤¬¸½ºß¤Î¥¿¥¤¥à¥¾¡¼¥ó¤ËÀßÄꤵ¤ì¤ë¡£
272 Í×ÁÇÊ̤λþ¹ï¤ò¥«¥ì¥ó¥À¡¼»þ¹ï (µª¸µ (Epoch) ¤«¤é¤ÎÉÿô) ¤Çɽ¸½¤Ç¤¤Ê¤¤¾ì¹ç¡¢
276 ¤òÊÖ¤·¡¢Í×ÁÇÊ̤λþ¹ï¤Î¹½Â¤ÂÎ¥á¥ó¥Ð¡¼¤òÊѹ¹¤·¤Ê¤¤¡£
278 ³Æ´Ø¿ô¤Ï¤½¤ì¤¾¤ìÁ°½Ò¤·¤¿ÃͤòÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï NULL
295 ¤òÇÑ»ßͽÄê¤È¤·¤Æ¤¤¤ë¡£
298 ¤Î»ÈÍѤ¬¿ä¾©¤µ¤ì¤Æ¤¤¤ë¡£
304 ¤Î 4 ¤Ä¤Î´Ø¿ô¤ÏÀÅŪ¥Ç¡¼¥¿¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¤Î¤Ç¡¢¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤Ç¤Ï¤Ê¤¤¡£
305 ¤³¤ì¤é¤Î´Ø¿ô¤Î¥¹¥ì¥Ã¥É¥»¡¼¥ÕÈǤǤ¢¤ë
310 ¤Ï SUSv2 ¤Çµ¬Äꤵ¤ì¤Æ¤ª¤ê¡¢
311 libc 5.2.5 °Ê¹ß¤ÇÍøÍѤǤ¤ë¡£
313 POSIX.1-2001 ¤Ç¤Ï¡¢¡Ö´Ø¿ô
318 ¤Ï¡¢Í×ÁÇÊ̤λþ¹ï¤Î¹½Â¤ÂΤ«
320 ·¿¤ÎÇÛÎ󤫤ΤɤÁ¤é¤«¤ÎÀÅŪ¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹¤â¤Î¤È¤¹¤ë¡£
321 ¤³¤ì¤é¤Î´Ø¿ô¤Î¤¤¤º¤ì¤«¤ò¼Â¹Ô¤¹¤ë¤È¡¢Â¾¤Î´Ø¿ô¤Î¤É¤ì¤«¤¬¤³¤ì¤é¤Î
322 ÀÅŪ¥ª¥Ö¥¸¥§¥¯¥È¤Î¤É¤Á¤é¤«¤Ë³ÊǼ¤·¤ÆÊÖ¤·¤¿¾ðÊ󤬾å½ñ¤¤µ¤ì¤ë¤«¤â
323 ¤·¤ì¤Ê¤¤¡£¡×¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
324 ¤³¤Î¤³¤È¤Ï glibc ¤Î¼ÂÁõ¤Çµ¯¤³¤ê¤¦¤ë¡£
326 glibc ¤ò´Þ¤à¿¤¯¤Î¼ÂÁõ¤Ç¤Ï¡¢
328 ¤Ë 0 ¤ò»ØÄꤹ¤ë¤ÈÁ°·î¤ÎºÇ½ªÆü¤ò°ÕÌ£¤·¤Æ¤¤¤ë¤È²ò¼á¤µ¤ì¤ë¡£
332 ¤¬¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤ëÁ°¤Ë
335 \fIstruct tm\fP ¤Ë°Ê²¼¤Î¥Õ¥£¡¼¥ë¥É¤¬Äɲ䵤ì¤ë¡£
339 long tm_gmtoff; /* Seconds east of UTC */
340 const char *tm_zone; /* Timezone abbreviation */
344 ¤³¤ì¤Ï BSD ³ÈÄ¥¤Ç¤¢¤ê¡¢4.3BSD-Reno ¤«¤é¸½¤ì¤¿¡£
346 POSIX.1-2004 ¤Ë¤è¤ë¤È¡¢
350 ¤¬¸Æ¤Ð¤ì¤¿¤«¤Î¤è¤¦¤Ë¿¶Éñ¤¦¤³¤È¤¬Í׵ᤵ¤ì¤Æ¤¤¤ë¤¬¡¢
353 .\" http://thread.gmane.org/gmane.comp.time.tz/2034/ ¤ò»²¾È¡£
354 °Ü¿¢À¤¬É¬Íפʥ³¡¼¥É¤Ç¤Ï¡¢
358 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤ª¤¯¤Ù¤¤Ç¤¢¤ë¡£
361 .BR gettimeofday (2),