Rechercher une page de manuel
timegm
Langue: ja
Version: 2001-12-26 (mandriva - 01/05/08)
Section: 3 (Bibliothèques de fonctions)
名前
timegm, timelocal - gmtime と localtime の逆関数書式
#include <time.h> time_t timelocal(struct tm *tm); time_t timegm(struct tm *tm);
説明
timelocal() 関数と timegm() 関数は、それぞれ localtime(3) 関数と gmtime(3) 関数の逆関数である。準拠
POSIX.1-2001 にはない。 BSD 系に存在する。注意
これらの関数は GNU の拡張である。 timelocal() 関数は POSIX の標準関数 mktime(3) と同じものである。 ので、これを使う理由はないはずである。timegm() を移植性があるようなかたちで実現するには、 TZ 環境変数を UTC に設定してから mktime(3) を呼んで、 TZ の値を取得すればよい。 例えば次のようになるだろう。
-
#include <time.h> #include <stdlib.h> time_t my_timegm (struct tm *tm) { time_t ret; char *tz; tz = getenv("TZ"); setenv("TZ", "", 1); tzset(); ret = mktime(tm); if (tz) setenv("TZ", tz, 1); else unsetenv("TZ"); tzset(); return ret; }
関連項目
gmtime(3), localtime(3), mktime(3), tzset(3)Contenus ©2006-2023 Benjamin Poulain
Design ©2006-2023 Maxime Vantorre