unixtodos

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

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


ヘッダーファイル

dos.h

カテゴリ

日付/時刻ルーチン

プロトタイプ

void unixtodos(long time, struct date *d, struct time *t);

説明

UNIX の日時を DOS 形式に変換します。

unixtodos は,time で指定される UNIX 形式の時刻を DOS 形式に変換し,その値を d と t が指す date 構造体と time 構造体に挿入します。

time は,1980 年 1 月 1 日 00 時 00 分 00 秒より前のカレンダー時刻を表してはなりません。

戻り値

なし。



 #include <stdio.h>
 #include <dos.h>
 char *month[] = {"---", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
                         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
 #define SECONDS_PER_DAY 86400L  /* 1 日当たりの秒数 */
 struct date dt;
 struct time tm;
 int main(void)
 {
    unsigned long val;
 /* 現在の日付と時刻を取得します */
    getdate(&dt);
    gettime(&tm);
    printf("today is %d %s %d\n", dt.da_day, month[dt.da_mon], dt.da_year);
 /*日付と時刻を UNIX 形式(1970 年 1 月 1 日からの秒数)に変換します*/
    val = dostounix(&dt, &tm);
 /* 42 日分の秒数を減算します */
    val -= (SECONDS_PER_DAY * 42);
 /* DOS 形式の時刻と日付に逆変換します */
    unixtodos(val, &dt, &tm);
    printf("42 days ago it was %d %s %d\n",
           dt.da_day, month[dt.da_mon], dt.da_year);
    return 0;
 }



移植性



POSIX Win32 ANSI C ANSI C++

+