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"
50 .\"O asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r,
51 .\"O localtime_r \- transform date and time to broken-down time or ASCII
52 asctime, ctime, gmtime, localtime, mktime, asctime_r, ctime_r, gmtime_r,
53 localtime_r \- 日付と時刻を要素別の時刻や ASCII に変換する
59 .BI "char *asctime(const struct tm *" tm );
61 .BI "char *asctime_r(const struct tm *" tm ", char *" buf );
63 .BI "char *ctime(const time_t *" timep );
65 .BI "char *ctime_r(const time_t *" timep ", char *" buf );
67 .BI "struct tm *gmtime(const time_t *" timep );
69 .BI "struct tm *gmtime_r(const time_t *" timep ", struct tm *" result );
71 .BI "struct tm *localtime(const time_t *" timep );
73 .BI "struct tm *localtime_r(const time_t *" timep ", struct tm *" result );
75 .BI "time_t mktime(struct tm *" tm );
79 .\"O Feature Test Macro Requirements for glibc (see
80 .\"O .BR feature_test_macros (7)):
82 .RB ( feature_test_macros (7)
92 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
93 _SVID_SOURCE || _POSIX_SOURCE
102 .\"O .BR localtime ()
103 .\"O functions all take
104 .\"O an argument of data type \fItime_t\fP which represents calendar time.
105 .\"O When interpreted as an absolute time value, it represents the number of
106 .\"O seconds elapsed since the Epoch, 1970-01-01 00:00:00 +0000 (UTC).
112 \fItime_t\fP 型のカレンダー時刻を引き数にとる。
113 引き数が絶対値として解釈される場合は、時刻紀元 (Epoch;
114 1970-01-01 00:00:00 +0000 (UTC)) からの経過秒数と解釈される。
120 .\"O functions both take an argument
121 .\"O representing broken-down time which is a representation
122 .\"O separated into year, month, day, etc.
128 年・月・日などに分離された要素別の時刻を引き数とする。
130 .\"O Broken-down time is stored
131 .\"O in the structure \fItm\fP which is defined in \fI<time.h>\fP as follows:
132 要素別の時刻は \fI<time.h>\fP で以下のように定義されている
138 .\"O int tm_sec; /* seconds */
139 .\"O int tm_min; /* minutes */
140 .\"O int tm_hour; /* hours */
141 .\"O int tm_mday; /* day of the month */
142 .\"O int tm_mon; /* month */
143 .\"O int tm_year; /* year */
144 .\"O int tm_wday; /* day of the week */
145 .\"O int tm_yday; /* day in the year */
146 .\"O int tm_isdst; /* daylight saving time */
149 int tm_hour; /* 時間 */
153 int tm_wday; /* 曜日 */
154 int tm_yday; /* 年内通算日 */
155 int tm_isdst; /* 夏時間 */
160 .\"O The members of the \fItm\fP structure are:
161 \fItm\fP 構造体のメンバーは以下の通り:
164 .\"O The number of seconds after the minute, normally in the range 0 to 59,
165 .\"O but can be up to 60 to allow for leap seconds.
166 秒数、ふつうは 0 から 59 までの値、
167 しかし閏秒のため 60 までの値は許される。
170 .\"O The number of minutes after the hour, in the range 0 to 59.
174 .\"O The number of hours past midnight, in the range 0 to 23.
175 真夜中からの通算時間、0 から 23 までの値。
178 .\"O The day of the month, in the range 1 to 31.
179 月はじめからの日数、1 から 31 までの値。
182 .\"O The number of months since January, in the range 0 to 11.
183 1月からの通算月数、0 から 11 までの値。
186 .\"O The number of years since 1900.
190 .\"O The number of days since Sunday, in the range 0 to 6.
191 日曜日からの通算日数(曜日)。0 から 6 までの値。
194 .\"O The number of days since January 1, in the range 0 to 365.
195 1 月 1 日からの通算日数、0 から 365 までの値。
198 .\"O A flag that indicates whether daylight saving time is in effect at the
200 .\"O The value is positive if daylight saving time is in
201 .\"O effect, zero if it is not, and negative if the information is not
204 正の値ならば夏時間は有効になり、0 ならば無効、負の値ならばこの情報には
209 .\"O is equivalent to
210 .\"O .BI asctime(localtime( t )) \fR.
211 .\"O It converts the calendar time \fIt\fP into a
212 .\"O null-terminated string of the form
215 .\"O "Wed Jun 30 21:49:08 1993\\n"
220 .BI asctime(localtime( t ))
225 "Wed Jun 30 21:49:08 1993\\n"
228 という形式の NULL 終端された文字列へ変換する。
229 .\"O The abbreviations for the days of the week are "Sun", "Mon", "Tue", "Wed",
230 .\"O "Thu", "Fri", and "Sat".
231 .\"O The abbreviations for the months are "Jan",
232 .\"O "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", and
234 .\"O The return value points to a statically allocated string which
235 .\"O might be overwritten by subsequent calls to any of the date and time
237 .\"O The function also sets the external
238 .\"O variables \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP (see
240 .\"O with information about the current timezone.
242 "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" である。
243 月の略称は "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
244 "Sep", "Oct", "Nov", "Dec" である。
245 返り値は、静的 (static) に割り当てられた文字列へのポインタである。
246 この文字列は、日付・時刻関数のいずれかが呼び出されると上書きされることがある。
247 またこの関数は大域変数 \fItzname\fP, \fItimezone\fP, \fIdaylight\fP
251 .\"O The reentrant version
253 .\"O does the same, but stores the
254 .\"O string in a user-supplied buffer
255 .\"O which should have room for at least 26 bytes.
257 .\"O set \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP.
261 文字列はユーザーが用意したバッファに格納される。バッファのサイズは
262 少なくとも 26 バイト以上でなければならない。
263 この関数は \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP
268 .\"O function converts the calendar time \fItimep\fP to
269 .\"O broken-down time representation, expressed in Coordinated Universal Time
271 .\"O It may return NULL when the year does not fit into an integer.
274 は、カレンダー時刻 \fItimep\fP を
275 協定世界時 (UTC) での要素別の時刻へ変換する。
276 年が整数型に収まらない場合、NULL を返す。
277 .\"O The return value points to a statically allocated struct which might be
278 .\"O overwritten by subsequent calls to any of the date and time functions.
279 返り値は静的に確保された構造体を指しており、この後で
280 日付や時刻に関する関数のいずれかが呼び出されると
284 .\"O function does the same, but stores the data in a
285 .\"O user-supplied struct.
288 データはユーザーが用意した構造体に格納される。
291 .\"O .BR localtime ()
292 .\"O function converts the calendar time \fItimep\fP to
293 .\"O broken-down time representation,
294 .\"O expressed relative to the user's specified timezone.
295 .\"O The function acts as if it called
297 .\"O and sets the external variables \fItzname\fP with
298 .\"O information about the current timezone, \fItimezone\fP with the difference
299 .\"O between Coordinated Universal Time (UTC) and local standard time in
300 .\"O seconds, and \fIdaylight\fP to a nonzero value if daylight savings
301 .\"O time rules apply during some part of the year.
304 は、カレンダー時刻 \fItimep\fP を
305 ユーザが指定したタイムゾーンでの時刻要素別の表現へ変換する。
309 大域変数 \fItzname\fP に現在のタイムゾーンの情報を設定する。
310 また、\fItimezone\fP に協定世界時 (UTC) とローカル標準時との
312 一年の一部で夏時間が適用される場合は \fIdaylight\fP に 0 が設定される。
313 .\"O The return value points to a statically allocated struct which might be
314 .\"O overwritten by subsequent calls to any of the date and time functions.
315 返り値は静的に確保された構造体を指しており、この後で
316 日付や時刻に関する関数のいずれかが呼び出されると
319 .\"O .BR localtime_r ()
320 .\"O function does the same, but stores the data in a
321 .\"O user-supplied struct.
322 .\"O It need not set \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP.
325 データはユーザーが用意した構造体に格納される。
326 この関数は \fItzname\fP, \fItimezone\fP, and \fIdaylight\fP
331 .\"O function converts the broken-down time value
332 .\"O \fItm\fP into a null-terminated string with the same format as
334 .\"O The return value points to a statically allocated string which might be
335 .\"O overwritten by subsequent calls to any of the date and time functions.
340 と同じ形式の NULL 終端された文字列へ変換する。
341 返り値は静的に割り当てられた文字列へのポインタである。この文字列は、
342 日付・時刻関数のいずれかが呼び出されると上書きされることがある。
344 .\"O .BR asctime_r ()
345 .\"O function does the same, but stores the string in
346 .\"O a user-supplied buffer which should have room for at least 26 bytes.
350 文字列はユーザーが用意したバッファに格納される。バッファのサイズは
351 少なくとも 26 バイト以上でなければならない。
355 .\"O function converts a broken-down time structure, expressed
356 .\"O as local time, to calendar time representation.
357 .\"O The function ignores
358 .\"O the values supplied by the caller in the
363 .\"O The value specified in the
367 .\"O whether or not daylight saving time (DST)
368 .\"O is in effect for the time supplied in the
371 .\"O a positive value means DST is in effect;
372 .\"O zero means that DST is not in effect;
373 .\"O and a negative value means that
375 .\"O should (use timezone information and system databases to)
376 .\"O attempt to determine whether DST is in effect at the specified time.
379 は、(ローカルタイムで記述されている) 要素別の時刻を
380 カレンダー時刻へ変換する。この際、呼び出し元がフィールド
390 構造体で渡された時刻で夏時間 (daylight saving time; DST) が有効になって
392 正の値は夏時間が有効であることを意味する。
395 は (タイムゾーン情報とシステムのデータベースを使って)
396 指定された時刻で夏時間が有効かどうかを判断する必要があることを意味する。
400 .\"O function modifies the fields of the
402 .\"O structure as follows:
406 .\"O are set to values determined from the contents of the other fields;
410 構造体の各フィールドを以下のように修正する。
414 には他のフィールドの内容から求めた値を設定する。
415 .\"O if structure members are outside their valid interval, they will be
416 .\"O normalized (so that, for example, 40 October is changed into 9 November);
418 .\"O is set (regardless of its initial value)
419 .\"O to a positive value or to 0, respectively,
420 .\"O to indicate whether DST is or is not in effect at the specified time.
421 構造体の要素が有効な範囲にない場合、正規化される
422 (例えば、10 月 40 日は 11 月 9 日に変更される)。
424 には (最初の値にかかわらず) 正の値か 0 が設定される。
425 正の値は指定された時間で夏時間が有効であることを示し、
429 .\"O also sets the external variable \fItzname\fP with
430 .\"O information about the current timezone.
434 大域変数 \fItzname\fP が現在のタイムゾーンに設定される。
436 .\"O If the specified broken-down
437 .\"O time cannot be represented as calendar time (seconds since the Epoch),
440 .\"O .I (time_t)\ \-1
441 .\"O and does not alter the
442 .\"O members of the broken-down time structure.
443 要素別の時刻をカレンダー時刻 (紀元 (Epoch) からの秒数) で表現できない場合、
447 を返し、要素別の時刻の構造体メンバーを変更しない。
448 .\"O .SH "RETURN VALUE"
450 .\"O Each of these functions returns the value described, or NULL
453 .\"O in case an error was detected.
454 各関数はそれぞれ前述した値を返す。エラーの場合は NULL
459 .\"O C89 and C99 specify
463 .\"O .BR localtime (),
474 .\"O POSIX.1-2008 marks
476 .\"O .BR asctime_r (),
481 .\"O recommending the use of
482 .\"O .BR strftime (3)
495 .\"O The four functions
500 .\"O .BR localtime ()
501 .\"O return a pointer to static data and hence are not thread-safe.
506 の 4 つの関数は静的データへのポインタを返すので、スレッドセーフではない。
507 .\"O Thread-safe versions
508 .\"O .BR asctime_r (),
512 .\"O .BR localtime_r ()
513 .\"O are specified by SUSv2, and available since libc 5.2.5.
522 .\"O POSIX.1-2001 says:
528 .\"O .BR localtime ()
529 .\"O functions shall return values in one of two static objects:
530 .\"O a broken-down time structure and an array of type
532 .\"O Execution of any of the functions may overwrite the information returned
533 .\"O in either of these objects by any of the other functions."
534 .\"O This can occur in the glibc implementation.
542 型の配列かのどちらかの静的オブジェクトを返すものとする。
543 これらの関数のいずれかを実行すると、他の関数のどれかがこれらの
544 静的オブジェクトのどちらかに格納して返した情報が上書きされるかも
546 このことは glibc の実装で起こりうる。
548 .\"O In many implementations, including glibc, a 0 in
550 .\"O is interpreted as meaning the last day of the preceding month.
553 に 0 を指定すると前月の最終日を意味していると解釈される。
555 .\"O The glibc version of \fIstruct tm\fP has additional fields
559 .\"O long tm_gmtoff; /* Seconds east of UTC */
560 .\"O const char *tm_zone; /* Timezone abbreviation */
566 .\"O was set before including
573 \fIstruct tm\fP に以下のフィールドが追加される。
577 long tm_gmtoff; /* Seconds east of UTC */
578 const char *tm_zone; /* Timezone abbreviation */
582 .\"O This is a BSD extension, present in 4.3BSD-Reno.
583 これは BSD 拡張であり、4.3BSD-Reno から現れた。
585 .\"O According to POSIX.1-2004,
586 .\"O .BR localtime ()
587 .\"O is required to behave as though
589 .\"O was called, while
590 .\"O .BR localtime_r ()
591 .\"O does not have this requirement.
592 .\"O .\" See http://thread.gmane.org/gmane.comp.time.tz/2034/
593 .\"O For portable code
595 .\"O should be called before
596 .\"O .BR localtime_r ().
601 が呼ばれたかのように振舞うことが要求されているが、
604 .\" http://thread.gmane.org/gmane.comp.time.tz/2034/ を参照。
613 .BR gettimeofday (2),