ftime

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

sys\timeb.h:インデックス への移動


ヘッダーファイル

sys\timeb.h

カテゴリ

日付/時刻ルーチン

プロトタイプ

void ftime(struct timeb *buf)

説明

現在の時刻を timeb 構造体に格納します。

UNIX プラットフォームの場合,ftime は,System V システム内でのみ使用できます。

ftime は,現在の時刻を取得し,それを buf が指す timeb 構造体のフィールドに設定します。timeb 構造体には,4 つのフィールド(time,millitm,_timezone,dstflag)があります。

struct timeb {

long time ;

short millitm ;

short _timezone ;

short dstflag ;

};

  • time は,1970 年 1 月 1 日グリニッジ標準時(GMT)00 時 00 分 00 秒からの秒数で時刻を提供します。
  • millitm は,秒の小数部分です(ミリ秒単位)。
  • _timezone は,GMT と地域時間との時差です(分単位)。この値は,GMT から西向きに計算されます。ftime は,このフィールドを tzset によって設定されるグローバル変数 _timezone から取得します。
  • dstflag は,時刻の計算に夏時間を適用する場合,0 以外の値に設定されます。

メモ:  ftime は tzset を呼び出します。したがって,ftime を使用する場合,tzset を明示的に呼び出す必要はありません。

戻り値

なし。



 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <sys\timeb.h>
 /* 太平洋標準時と夏時間調整 */
 char *tzstr = "TZ=PST8PDT";
 int main(void)
 {
    struct timeb t;
    putenv(tzstr);
    tzset();
    ftime(&t);
    printf("Seconds since 1/1/1970 GMT: %ld\n", t.time);
    printf("Thousandths of a second: %d\n", t.millitm);
    printf("Difference between local time and GMT: %d\n", t._timezone);
    printf("Daylight savings in effect (1) not (0): %d\n", t.dstflag);
    return 0;
 }



移植性



POSIX Win32 ANSI C ANSI C++

+