localtime_r

提供: RAD Studio
移動先: 案内検索

Time.h:インデックス への移動


ヘッダー ファイル

time.h

カテゴリ

日付/時刻ルーチン

プロトタイプ

struct tm *localtime_r( const time_t *timer, struct tm *buf );

説明

日付と時刻を構造体に変換します。

localtime_r は、時間によって返された値のアドレスを受取り、時間要素を格納する型 tm の構造体へのポインタを返します。これは、タイムゾーンと夏時間の場合にはそれに合わせて修正します。

tm 構造体については、「localtime」を参照してください。

戻り値

localtime_r は、成功した場合には result を、そうでなければ null を返します。

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
  time_t t = time(NULL);
  struct tm tmbuf;
  char buf[30];
  printf("UTC:       %s", asctime_r(gmtime_r(&t, &tmbuf), buf));
  printf("local:     %s", asctime_r(localtime_r(&t, &tmbuf), buf));
}

移植性

POSIX Win32 ANSI C ANSI C++

+

+

+

+

関連項目