[英]Using pywin32 DosDateTimeToTime to unpack DOS packed time
有沒有人使用pywin32 pywintypes.DosDateTimetoTime將DOS打包的日期/時間結構轉換為Python中的可讀時間格式?
我無法找到有關如何使用此功能的文檔,需要哪些參數以及采用何種格式。
我正在編寫一個腳本來從舊的DOS備份文件中提取文件,基本上是嘗試復制舊的DOS恢復命令。 我正在根據找到的備份文件格式提取文件http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/restore/brtecdoc.htm
謝謝,傑伊
它需要兩個參數(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鏈接中描述的格式以及下面復制的相關部分:
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.