Scroll to navigation

TIMEGM(3) Linux Programmer's Manual TIMEGM(3)

名前

timegm, timelocal - gmtime と localtime の逆関数

書式

#include <time.h>
time_t timelocal(struct tm *tm);
time_t timegm(struct tm *tm);

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

timelocal(), timegm():
Since glibc 2.19:
_DEFAULT_SOURCE
Glibc 2.19 and earlier:
_BSD_SOURCE || _SVID_SOURCE

説明

The functions timelocal() and timegm() are the inverses of localtime(3) and gmtime(3). Both functions take a broken-down time and convert it to calendar time (seconds since the Epoch, 1970-01-01 00:00:00 +0000, UTC). The difference between the two functions is that timelocal() takes the local timezone into account when doing the conversion, while timegm() takes the input value to be Coordinated Universal Time (UTC).

返り値

On success, these functions return the calendar time (seconds since the Epoch), expressed as a value of type time_t. On error, they return the value (time_t) -1 and set errno to indicate the cause of the error.

エラー

The result cannot be represented.

属性

この節で使用されている用語の説明については、 attributes(7) を参照。

インターフェース 属性
timelocal(), timegm() Thread safety MT-Safe env locale

準拠

これらの関数は非標準で GNU の拡張である。 BSD 系にも存在する。 これらの使用は避けること。

注意

timelocal() 関数は POSIX の標準関数 mktime(3) と同じものである。 ので、これを使う理由はないはずである。

関連項目

gmtime(3), localtime(3), mktime(3), tzset(3)

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

2016-12-12 GNU