请输入您要查询的百科知识:

 

词条 unixtodos
释义

函数名: unixtodos

功 能: 把日期和时间转换成DOS格式

用 法: void unixtodos(long utime, struct date *dateptr,

struct time *timeptr);

程序例:

#include

#include

char *month[] = {"---", "Jan", "Feb", "Mar", "Apr", "May", "Jun",

"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

#define SECONDS_PER_DAY 86400L /* the number of seconds in one day */

struct date dt;

struct time tm;

int main(void)

{

unsigned long val;

/* get today's date and time */

getdate(&dt);

gettime(&tm);

printf("today is %d %s %d\", dt.da_day, month[dt.da_mon], dt.da_year);

/* convert date and time to unix format (number of seconds since Jan 1, 1970 */

val = dostounix(&dt, &tm);

/* subtract 42 days worth of seconds */

val -= (SECONDS_PER_DAY * 42);

/* convert back to dos time and date */

unixtodos(val, &dt, &tm);

printf("42 days ago it was %d %s %d\",

dt.da_day, month[dt.da_mon], dt.da_year);

return 0;

}

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2024/11/16 16:33:34