.\" Copyright (C) 2001 Andries Brouwer .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 2002 NAKANO Takeo all rights reserved. .\" Translated Thu 3 Jan 2002 by NAKANO Takeo .\" .TH TIMEGM 3 2013\-07\-04 GNU "Linux Programmer's Manual" .SH 名前 timegm, timelocal \- gmtime と localtime の逆関数 .SH 書式 .nf \fB#include \fP .sp \fBtime_t timelocal(struct tm *\fP\fItm\fP\fB);\fP .sp \fBtime_t timegm(struct tm *\fP\fItm\fP\fB);\fP .sp .fi .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBtimelocal\fP(), \fBtimegm\fP(): _BSD_SOURCE || _SVID_SOURCE .SH 説明 \fBtimelocal\fP() 関数と \fBtimegm\fP() 関数は、それぞれ \fBlocaltime\fP(3) 関数と \fBgmtime\fP(3) 関数の逆関数である。 .SH 準拠 これらの関数は非標準で GNU の拡張である。 BSD 系にも存在する。 これらの使用は避けること。「注意」参照。 .SH 注意 \fBtimelocal\fP() 関数は POSIX の標準関数 \fBmktime\fP(3) と同じものである。 ので、これを使う理由はないはずである。 .LP \fBtimegm\fP() を移植性があるようなかたちで実現するには、 \fBTZ\fP 環境変数を UTC に設定してから \fBmktime\fP(3) を呼んで、 \fBTZ\fP の値を取得すればよい。 例えば次のようになるだろう。 .in +4n .nf #include #include time_t my_timegm (struct tm *tm) { time_t ret; char *tz; tz = getenv("TZ"); if (tz) tz = strdup(tz); setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz) { setenv("TZ", tz, 1); free(tz); } else unsetenv("TZ"); tzset(); return ret; } .fi .in .SH 関連項目 \fBgmtime\fP(3), \fBlocaltime\fP(3), \fBmktime\fP(3), \fBtzset\fP(3) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。