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)
85 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
86 _SVID_SOURCE || _POSIX_SOURCE
93 \fItime_t\fP ·¿¤Î¥«¥ì¥ó¥À¡¼»þ¹ï¤ò°ú¤¿ô¤Ë¤È¤ë¡£
94 °ú¤¿ô¤¬ÀäÂÐÃͤȤ·¤Æ²ò¼á¤µ¤ì¤ë¾ì¹ç¤Ï¡¢»þ¹ïµª¸µ (Epoch;
95 1970-01-01 00:00:00 +0000 (UTC)) ¤«¤é¤Î·Ð²áÉÿô¤È²ò¼á¤µ¤ì¤ë¡£
102 ǯ¡¦·î¡¦Æü¤Ê¤É¤ËʬΥ¤µ¤ì¤¿Í×ÁÇÊ̤λþ¹ï¤ò°ú¤¿ô¤È¤¹¤ë¡£
104 Í×ÁÇÊ̤λþ¹ï¤Ï \fI<time.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë
105 \fItm\fP ¹½Â¤ÂΤËÊÝ»ý¤µ¤ì¤ë¡£
112 int tm_hour; /* »þ´Ö */
113 int tm_mday; /* Æü */
116 int tm_wday; /* ÍËÆü */
117 int tm_yday; /* ǯÆâÄÌ»»Æü */
118 int tm_isdst; /* ²Æ»þ´Ö */
123 \fItm\fP ¹½Â¤ÂΤΥá¥ó¥Ð¡¼¤Ï°Ê²¼¤ÎÄ̤ê:
126 Éÿô¡¢¤Õ¤Ä¤¦¤Ï 0 ¤«¤é 59 ¤Þ¤Ç¤ÎÃÍ¡¢
127 ¤·¤«¤·±¼ÉäΤ¿¤á 60 ¤Þ¤Ç¤ÎÃͤϵö¤µ¤ì¤ë¡£
130 ʬ¿ô¡¢0 ¤«¤é 59 ¤Þ¤Ç¤ÎÃÍ¡£
133 ¿¿ÌëÃ椫¤é¤ÎÄÌ»»»þ´Ö¡¢0 ¤«¤é 23 ¤Þ¤Ç¤ÎÃÍ¡£
136 ·î¤Ï¤¸¤á¤«¤é¤ÎÆü¿ô¡¢1 ¤«¤é 31 ¤Þ¤Ç¤ÎÃÍ¡£
139 1·î¤«¤é¤ÎÄÌ»»·î¿ô¡¢0 ¤«¤é 11 ¤Þ¤Ç¤ÎÃÍ¡£
142 1900 ǯ¤«¤é¤ÎÄÌ»»Ç¯¿ô¡£
145 ÆüÍËÆü¤«¤é¤ÎÄÌ»»Æü¿ô(ÍËÆü)¡£0 ¤«¤é 6 ¤Þ¤Ç¤ÎÃÍ¡£
148 1 ·î 1 Æü¤«¤é¤ÎÄÌ»»Æü¿ô¡¢0 ¤«¤é 365 ¤Þ¤Ç¤ÎÃÍ¡£
151 ²Æ»þ´Ö¤¬Í¸ú¤«¤É¤¦¤«¤Î¥Õ¥é¥°¡£
152 Àµ¤ÎÃͤʤé¤Ð²Æ»þ´Ö¤Ï͸ú¤Ë¤Ê¤ê¡¢0 ¤Ê¤é¤Ð̵¸ú¡¢Éé¤ÎÃͤʤé¤Ð¤³¤Î¾ðÊó¤Ë¤Ï
157 .BI asctime(localtime( t ))
159 ¥«¥ì¥ó¥À¡¼»þ¹ï \fIt\fP ¤ò
162 "Wed Jun 30 21:49:08 1993\\n"
165 ¤È¤¤¤¦·Á¼°¤Î NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤ØÊÑ´¹¤¹¤ë¡£
167 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ¤Ç¤¢¤ë¡£
168 ·î¤Îά¾Î¤Ï "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
169 "Sep", "Oct", "Nov", "Dec" ¤Ç¤¢¤ë¡£
170 ÊÖ¤êÃͤϡ¢ÀÅŪ (static) ¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£
171 ¤³¤Îʸ»úÎó¤Ï¡¢ÆüÉÕ¡¦»þ¹ï´Ø¿ô¤Î¤¤¤º¤ì¤«¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¾å½ñ¤¤µ¤ì¤ë¤³¤È¤¬¤¢¤ë¡£
172 ¤Þ¤¿¤³¤Î´Ø¿ô¤ÏÂç°èÊÑ¿ô \fItzname\fP, \fItimezone\fP, \fIdaylight\fP
173 ¤Ë¸½ºß¤Î¥¿¥¤¥à¥¾¡¼¥ó¤Î¾ðÊó¤òÀßÄꤹ¤ë
176 ¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤǤ¢¤ë
179 ʸ»úÎó¤Ï¥æ¡¼¥¶¡¼¤¬ÍÑ°Õ¤·¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º¤Ï
180 ¾¯¤Ê¤¯¤È¤â 26 ¥Ð¥¤¥È°Ê¾å¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
181 ¤³¤Î´Ø¿ô¤Ï \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP
182 ¤òÀßÄꤹ¤ëɬÍפϤʤ¤¡£
186 ¤Ï¡¢¥«¥ì¥ó¥À¡¼»þ¹ï \fItimep\fP ¤ò
187 ¶¨ÄêÀ¤³¦»þ (UTC) ¤Ç¤ÎÍ×ÁÇÊ̤λþ¹ï¤ØÊÑ´¹¤¹¤ë¡£
188 ǯ¤¬À°¿ô·¿¤Ë¼ý¤Þ¤é¤Ê¤¤¾ì¹ç¡¢NULL ¤òÊÖ¤¹¡£
189 ÊÖ¤êÃͤÏÀÅŪ¤Ë³ÎÊݤµ¤ì¤¿¹½Â¤ÂΤò»Ø¤·¤Æ¤ª¤ê¡¢¤³¤Î¸å¤Ç
190 ÆüÉÕ¤ä»þ¹ï¤Ë´Ø¤¹¤ë´Ø¿ô¤Î¤¤¤º¤ì¤«¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È
191 ¾å½ñ¤¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
194 ¥Ç¡¼¥¿¤Ï¥æ¡¼¥¶¡¼¤¬ÍÑ°Õ¤·¤¿¹½Â¤ÂΤ˳ÊǼ¤µ¤ì¤ë¡£
198 ¤Ï¡¢¥æ¡¼¥¶¤¬»ØÄꤷ¤¿¥¿¥¤¥à¥¾¡¼¥ó¤Ç¤Î»þ¹ïÍ×ÁǤØÊÑ´¹¤¹¤ë¡£
201 ¤ò¸Æ¤Ó½Ð¤·¤¿¤«¤Î¤è¤¦¤Ë¿¶Éñ¤¤¡¢
202 Âç°èÊÑ¿ô \fItzname\fP ¤Ë¸½ºß¤Î¥¿¥¤¥à¥¾¡¼¥ó¤Î¾ðÊó¤òÀßÄꤹ¤ë¡£
203 ¤Þ¤¿¡¢\fItimezone\fP ¤Ë¶¨ÄêÀ¤³¦»þ (UTC) ¤È¥í¡¼¥«¥ëɸ½à»þ¤È¤Î
205 °ìǯ¤Î°ìÉô¤Ç²Æ»þ´Ö¤¬Å¬ÍѤµ¤ì¤ë¾ì¹ç¤Ï \fIdaylight\fP ¤Ë 0 ¤¬ÀßÄꤵ¤ì¤ë¡£
206 ÊÖ¤êÃͤÏÀÅŪ¤Ë³ÎÊݤµ¤ì¤¿¹½Â¤ÂΤò»Ø¤·¤Æ¤ª¤ê¡¢¤³¤Î¸å¤Ç
207 ÆüÉÕ¤ä»þ¹ï¤Ë´Ø¤¹¤ë´Ø¿ô¤Î¤¤¤º¤ì¤«¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È
208 ¾å½ñ¤¤µ¤ì¤ë²ÄǽÀ¤¬¤¢¤ë¡£
211 ¥Ç¡¼¥¿¤Ï¥æ¡¼¥¶¡¼¤¬ÍÑ°Õ¤·¤¿¹½Â¤ÂΤ˳ÊǼ¤µ¤ì¤ë¡£
212 ¤³¤Î´Ø¿ô¤Ï \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP
213 ¤òÀßÄꤹ¤ëɬÍפϤʤ¤¡£
217 ¤Ï¡¢Í×ÁÇÊ̤λþ¹ï \fItm\fP ¤ò
219 ¤ÈƱ¤¸·Á¼°¤Î NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤ØÊÑ´¹¤¹¤ë¡£
220 ÊÖ¤êÃͤÏÀÅŪ¤Ë³ä¤êÅö¤Æ¤é¤ì¤¿Ê¸»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿¤Ç¤¢¤ë¡£¤³¤Îʸ»úÎó¤Ï¡¢
221 ÆüÉÕ¡¦»þ¹ï´Ø¿ô¤Î¤¤¤º¤ì¤«¤¬¸Æ¤Ó½Ð¤µ¤ì¤ë¤È¾å½ñ¤¤µ¤ì¤ë¤³¤È¤¬¤¢¤ë¡£
222 ¥ê¥¨¥ó¥È¥é¥ó¥ÈÈǤǤ¢¤ë
225 ʸ»úÎó¤Ï¥æ¡¼¥¶¡¼¤¬ÍÑ°Õ¤·¤¿¥Ð¥Ã¥Õ¥¡¤Ë³ÊǼ¤µ¤ì¤ë¡£¥Ð¥Ã¥Õ¥¡¤Î¥µ¥¤¥º¤Ï
226 ¾¯¤Ê¤¯¤È¤â 26 ¥Ð¥¤¥È°Ê¾å¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
230 ¤Ï¡¢(¥í¡¼¥«¥ë¥¿¥¤¥à¤Çµ½Ò¤µ¤ì¤Æ¤¤¤ë) Í×ÁÇÊ̤λþ¹ï¤ò
231 ¥«¥ì¥ó¥À¡¼»þ¹ï¤ØÊÑ´¹¤¹¤ë¡£¤³¤ÎºÝ¡¢¸Æ¤Ó½Ð¤·¸µ¤¬¥Õ¥£¡¼¥ë¥É
235 ¤Ç»ØÄꤷ¤¿ÃͤÏ̵»ë¤µ¤ì¤ë¡£
239 ¤Ç»ØÄꤵ¤ì¤¿Ãͤˤè¤ê¡¢
241 ¹½Â¤ÂΤÇÅϤµ¤ì¤¿»þ¹ï¤Ç²Æ»þ´Ö (daylight saving time; DST) ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ
243 Àµ¤ÎÃͤϲƻþ´Ö¤¬Í¸ú¤Ç¤¢¤ë¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
246 ¤Ï (¥¿¥¤¥à¥¾¡¼¥ó¾ðÊó¤È¥·¥¹¥Æ¥à¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò»È¤Ã¤Æ)
247 »ØÄꤵ¤ì¤¿»þ¹ï¤Ç²Æ»þ´Ö¤¬Í¸ú¤«¤É¤¦¤«¤òȽÃǤ¹¤ëɬÍפ¬¤¢¤ë¤³¤È¤ò°ÕÌ£¤¹¤ë¡£
252 ¹½Â¤ÂΤγƥե£¡¼¥ë¥É¤ò°Ê²¼¤Î¤è¤¦¤Ë½¤Àµ¤¹¤ë¡£
256 ¤Ë¤Ï¾¤Î¥Õ¥£¡¼¥ë¥É¤ÎÆâÍƤ«¤éµá¤á¤¿ÃͤòÀßÄꤹ¤ë¡£
257 ¹½Â¤ÂΤÎÍ×ÁǤ¬Í¸ú¤ÊÈϰϤˤʤ¤¾ì¹ç¡¢Àµµ¬²½¤µ¤ì¤ë
258 (Î㤨¤Ð¡¢10 ·î 40 Æü¤Ï 11 ·î 9 Æü¤ËÊѹ¹¤µ¤ì¤ë)¡£
260 ¤Ë¤Ï (ºÇ½é¤ÎÃͤˤ«¤«¤ï¤é¤º) Àµ¤ÎÃͤ« 0 ¤¬ÀßÄꤵ¤ì¤ë¡£
261 Àµ¤ÎÃͤϻØÄꤵ¤ì¤¿»þ´Ö¤Ç²Æ»þ´Ö¤¬Í¸ú¤Ç¤¢¤ë¤³¤È¤ò¼¨¤·¡¢
262 0 ¤Ï̵¸ú¤Ç¤¢¤ë¤³¤È¤ò¼¨¤¹¡£
266 Âç°èÊÑ¿ô \fItzname\fP ¤¬¸½ºß¤Î¥¿¥¤¥à¥¾¡¼¥ó¤ËÀßÄꤵ¤ì¤ë¡£
268 Í×ÁÇÊ̤λþ¹ï¤ò¥«¥ì¥ó¥À¡¼»þ¹ï (µª¸µ (Epoch) ¤«¤é¤ÎÉÿô) ¤Çɽ¸½¤Ç¤¤Ê¤¤¾ì¹ç¡¢
272 ¤òÊÖ¤·¡¢Í×ÁÇÊ̤λþ¹ï¤Î¹½Â¤ÂÎ¥á¥ó¥Ð¡¼¤òÊѹ¹¤·¤Ê¤¤¡£
274 ³Æ´Ø¿ô¤Ï¤½¤ì¤¾¤ìÁ°½Ò¤·¤¿ÃͤòÊÖ¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï NULL
291 ¤òÇÑ»ßͽÄê¤È¤·¤Æ¤¤¤ë¡£
294 ¤Î»ÈÍѤ¬¿ä¾©¤µ¤ì¤Æ¤¤¤ë¡£
300 ¤Î 4 ¤Ä¤Î´Ø¿ô¤ÏÀÅŪ¥Ç¡¼¥¿¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÊÖ¤¹¤Î¤Ç¡¢¥¹¥ì¥Ã¥É¥»¡¼¥Õ¤Ç¤Ï¤Ê¤¤¡£
301 ¤³¤ì¤é¤Î´Ø¿ô¤Î¥¹¥ì¥Ã¥É¥»¡¼¥ÕÈǤǤ¢¤ë
306 ¤Ï SUSv2 ¤Çµ¬Äꤵ¤ì¤Æ¤ª¤ê¡¢
307 libc 5.2.5 °Ê¹ß¤ÇÍøÍѤǤ¤ë¡£
309 POSIX.1-2001 ¤Ç¤Ï¡¢¡Ö´Ø¿ô
314 ¤Ï¡¢Í×ÁÇÊ̤λþ¹ï¤Î¹½Â¤ÂΤ«
316 ·¿¤ÎÇÛÎ󤫤ΤɤÁ¤é¤«¤ÎÀÅŪ¥ª¥Ö¥¸¥§¥¯¥È¤òÊÖ¤¹¤â¤Î¤È¤¹¤ë¡£
317 ¤³¤ì¤é¤Î´Ø¿ô¤Î¤¤¤º¤ì¤«¤ò¼Â¹Ô¤¹¤ë¤È¡¢Â¾¤Î´Ø¿ô¤Î¤É¤ì¤«¤¬¤³¤ì¤é¤Î
318 ÀÅŪ¥ª¥Ö¥¸¥§¥¯¥È¤Î¤É¤Á¤é¤«¤Ë³ÊǼ¤·¤ÆÊÖ¤·¤¿¾ðÊ󤬾å½ñ¤¤µ¤ì¤ë¤«¤â
319 ¤·¤ì¤Ê¤¤¡£¡×¤È¤Ê¤Ã¤Æ¤¤¤ë¡£
320 ¤³¤Î¤³¤È¤Ï glibc ¤Î¼ÂÁõ¤Çµ¯¤³¤ê¤¦¤ë¡£
322 glibc ¤ò´Þ¤à¿¤¯¤Î¼ÂÁõ¤Ç¤Ï¡¢
324 ¤Ë 0 ¤ò»ØÄꤹ¤ë¤ÈÁ°·î¤ÎºÇ½ªÆü¤ò°ÕÌ£¤·¤Æ¤¤¤ë¤È²ò¼á¤µ¤ì¤ë¡£
328 ¤¬¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤ëÁ°¤Ë
331 \fIstruct tm\fP ¤Ë°Ê²¼¤Î¥Õ¥£¡¼¥ë¥É¤¬Äɲ䵤ì¤ë¡£
335 long tm_gmtoff; /* Seconds east of UTC */
336 const char *tm_zone; /* Timezone abbreviation */
340 ¤³¤ì¤Ï BSD ³ÈÄ¥¤Ç¤¢¤ê¡¢4.3BSD-Reno ¤«¤é¸½¤ì¤¿¡£
342 POSIX.1-2004 ¤Ë¤è¤ë¤È¡¢
346 ¤¬¸Æ¤Ð¤ì¤¿¤«¤Î¤è¤¦¤Ë¿¶Éñ¤¦¤³¤È¤¬Í׵ᤵ¤ì¤Æ¤¤¤ë¤¬¡¢
349 .\" http://thread.gmane.org/gmane.comp.time.tz/2034/ ¤ò»²¾È¡£
350 °Ü¿¢À¤¬É¬Íפʥ³¡¼¥É¤Ç¤Ï¡¢
354 ¤ò¸Æ¤Ó½Ð¤·¤Æ¤ª¤¯¤Ù¤¤Ç¤¢¤ë¡£
357 .BR gettimeofday (2),