简体   繁体   English

使用pywin32 DosDateTimeToTime解压缩DOS打包时间

[英]Using pywin32 DosDateTimeToTime to unpack DOS packed time

Has anyone used pywin32 pywintypes.DosDateTimetoTime to convert a DOS packed date/time structure to a readable time format in Python? 有没有人使用pywin32 pywintypes.DosDateTimetoTime将DOS打包的日期/时间结构转换为Python中的可读时间格式?

I am unable find much documentation on how to use this function, what parameters are required and in what format. 我无法找到有关如何使用此功能的文档,需要哪些参数以及采用何种格式。

I'm working on a script to extract files from an old DOS backup file, basically trying to replicate the old DOS restore command. 我正在编写一个脚本来从旧的DOS备份文件中提取文件,基本上是尝试复制旧的DOS恢复命令。 I'm working on extracting files based off the format of a backup file found http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/restore/brtecdoc.htm 我正在根据找到的备份文件格式提取文件http://www.ibiblio.org/pub/micro/pc-stuff/freedos/files/dos/restore/brtecdoc.htm

Thanks, Jay 谢谢,杰伊

It takes two parameters (16 bit integers) which are identical to the first two parameters of DosDateTimeToFileTime 它需要两个参数(16位整数),它们与DosDateTimeToFileTime的前两个参数相同

You can see that in the source code PyWinTypesmodule.cpp for pywin32: 您可以在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");
}

Those have to be of the format described in this MSDN link with the relevant parts copied below for convenience: 为方便起见,必须使用此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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM