中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-01 08:00
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » _dos_findfirst()_dos_findnext()得来的文件时间问题 查看 761 回复 0
楼 主 _dos_findfirst()_dos_findnext()得来的文件时间问题 发表于 2004-05-22 00:00 ·  中国 浙江 温州 瑞安市 电信
初级用户
积分 160
发帖 15
注册 2004-01-06 00:00
22年会员
UID 15000
性别 男
状态 离线
用_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;
论坛跳转: