Board logo

标题: _dos_findfirst()_dos_findnext()得来的文件时间问题 [打印本页]

作者: linzhixiao     时间: 2004-5-22 00:00    标题: _dos_findfirst()_dos_findnext()得来的文件时间问题
用_dos_findfirst()与_dos_findnext()函数得来的文件时间问题
struct find_t {
char reserved; /* reserved for use by DOS */
char attrib; /* attribute byte for file */
unsigned short wr_time; /* time of last write to file*/

unsigned short wr_date; /* date of last write to file*/
unsigned long size; /* length of file in bytes */
#if defined(__OS2__) || defined(__NT__)
char name; /* null-terminated filename */
#else
char name; /* null-terminated filename */
#endif
};
这个结构中的wr_date,wr_time字段,是日期跟时间,但它们是一个短整数(16位),
不是传统下的2004-05-22,与24:23:09这样的格式,请问高手如何能转换成这
样的格式,C语言中有没有现成的函数,或者如何再一个转换函数。


wr_date,wr_time中是这样的(如下结构)

typedef struct {
unsigned short twosecs : 5(0-4位); /* seconds / 2 */
unsigned short minutes : 6(5-19位); /* minutes (0,59) */
unsigned short hours : 5;(11-15位) /* hours (0,23) */
} ftime_t;

typedef struct {
unsigned short day : 5(0-4位); /* day (1,31) */
unsigned short month : 4;(5-8位) /* month (1,12) */
unsigned short year : 7;(9-位15) /* 0 is 1980 */
} fdate_t;