是否有人使用pywin32 pywintypes.DosDateTimetoTime将DOS打包日期/时间结构转换为Python中的可读时间格式?
我无法找到有关如何使用此功能的文档,需要哪些参数以及采用何种格式。
我正在编写一个脚本来从旧的DOS备份文件中提取文件,基本上是尝试复制旧的DOS恢复命令。我正在根据找到的http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/restore/brtecdoc.htm
备份文件的格式提取文件谢谢, 杰
答案 0 :(得分:1)
它需要两个参数(16位整数),它们与前两个参数相同 DosDateTimeToFileTime
你可以在pywin32的源代码PyWinTypesmodule.cpp中看到:
static PyObject *PyWin_DosDateTimeToTime(PyObject *self, PyObject *args)
{
WORD wFatDate, wFatTime;
if (!PyArg_ParseTuple(args, "hh", (WORD *)&wFatDate, (WORD *)&wFatTime))
return NULL;
FILETIME fd;
If (!DosDateTimeToFileTime(wFatDate, wFatTime, &fd))
return PyWin_SetAPIError("DosDateTimeToFileTime");
}
这些必须采用此MSDN link中描述的格式,并且为方便起见,下面复制了相关部分:
wFatDate [in]
The MS-DOS date. The date is a packed value with the following format.
Bits Description
0-4 Day of the month (1–31)
5-8 Month (1 = January, 2 = February, and so on)
9-15 Year offset from 1980 (add 1980 to get actual year)
wFatTime [in]
The MS-DOS time. The time is a packed value with the following format.
Bits Description
0-4 Second divided by 2
5-10 Minute (0–59)
11-15 Hour (0–23 on a 24-hour clock)