フォーマット
#include <time.h> struct tm *localtime_r(const time_t *timeval, struct tm *result);
言語レベル: XPG4
スレッド・セーフ: はい
ロケール依存: この関数の振る舞いは、現行ロケールの LC_TOD カテゴリーの影響を受ける可能性があります。
説明
この関数は、localtime() の再始動可能バージョンです。 戻される構造体 result が保管される場所を渡す点を除き、localtime() と同じです。
戻り値
localtime_r() は、構造体 result へのポインターを戻します。 エラーの戻り値はありません。
localtime_r() の使用例
この例では、システム・クロックを照会して、現地時間を表示します。
#include <time.h>
#include <stdio.h>
int main(void)
{
struct tm newtime;
time_t ltime;
char buf[50];
ltime=time(<ime);
localtime_r(<ime, &newtime);
printf("The date and time is %s", asctime_r(&newtime, buf));
}
/************** If the local time is 3 p.m. February 15, 2008, **********
************************* the output should be: *********************
The date and time is Fri Feb 15 15:00:00 2008
*/
関連情報