OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / man3 / timegm.3
1 .\" Copyright (C) 2001 Andries Brouwer <aeb@cwi.nl>
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\"*******************************************************************
24 .\"
25 .\" This file was generated with po4a. Translate the source file.
26 .\"
27 .\"*******************************************************************
28 .TH TIMEGM 3 2007\-07\-26 GNU "Linux Programmer's Manual"
29 .SH 名前
30 timegm, timelocal \- gmtime と localtime の逆関数
31 .SH 書式
32 .nf
33 \fB#include <time.h>\fP
34 .sp
35 \fBtime_t timelocal(struct tm *\fP\fItm\fP\fB);\fP
36 .sp
37 \fBtime_t timegm(struct tm *\fP\fItm\fP\fB);\fP
38 .sp
39 .fi
40 .in -4n
41 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
42 .in
43 .sp
44 \fBtimelocal\fP(), \fBtimegm\fP(): _BSD_SOURCE || _SVID_SOURCE
45 .SH 説明
46 \fBtimelocal\fP()  関数と \fBtimegm\fP()  関数は、それぞれ \fBlocaltime\fP(3)  関数と \fBgmtime\fP(3)
47 関数の逆関数である。
48 .SH 準拠
49 これらの関数は非標準で GNU の拡張である。 BSD 系にも存在する。 これらの使用は避けること。「注意」参照。
50 .SH 注意
51 \fBtimelocal\fP()  関数は POSIX の標準関数 \fBmktime\fP(3)  と同じものである。 ので、これを使う理由はないはずである。
52 .LP
53 \fBtimegm\fP()  を移植性があるようなかたちで実現するには、 \fBTZ\fP 環境変数を UTC に設定してから \fBmktime\fP(3)
54 を呼んで、 \fBTZ\fP の値を取得すればよい。 例えば次のようになるだろう。
55
56 .in +4n
57 .nf
58 #include <time.h>
59 #include <stdlib.h>
60
61 time_t my_timegm (struct tm *tm)
62 {
63     time_t ret;
64     char *tz;
65
66     tz = getenv("TZ");
67     setenv("TZ", "", 1);
68     tzset();
69     ret = mktime(tm);
70     if (tz)
71         setenv("TZ", tz, 1);
72     else
73         unsetenv("TZ");
74     tzset();
75     return ret;
76 }
77 .fi
78 .in
79 .SH 関連項目
80 \fBgmtime\fP(3), \fBlocaltime\fP(3), \fBmktime\fP(3), \fBtzset\fP(3)