フォーマット
#include <time.h> struct tm *gmtime_r(const time_t *time, struct tm *result);
言語レベル: XPG4
スレッド・セーフ: はい。
説明
この関数は、gmtime() の再始動可能バージョンです。
gmtime_r() 関数は、time 値を秒単位で分割し、result に保管します。result は、<time.h> で定義された tm 構造体を指すポインターです。 time 値は、通常、time() 関数を呼び出して取得します。
tm 構造体のフィールドには、以下のものがあります。
戻り値
gmtime_r() 関数は、結果である tm 構造体へポインターを戻します。
gmtime_r() の使用例
この例では、gmtime_r() 関数を使用して time_t 表記を協定世界時 (UTC) 文字ストリングへ調整し、次にそれを asctime_r() 関数を使用して出力可能なストリングに変換します。
#include <stdio.h> #include <time.h> int main(void) { time_t ltime; struct tm mytime; char buf[50]; time(<ime) printf ("Coordinated Universal Time is %s¥n", asctime_r(gmtime_r(<ime, &mytime), buf)); } /************************ Output should be similar to: ********** Coordinated Universal Time is Wed Aug 18 21:01:44 1993 */
関連情報