1.4. lf.time — Converters for various time formats

class lf.time.FILETIMEToPOSIXTime

Converts a FILETIME timestamp to a POSIX (unix) timestamp.

classmethod from_int(timestamp)

Converts a Microsoft Windows FILETIME timestamp to a POSIX timestamp.

Parameter:timestamp (int) – The FILETIME timestamp.
Return type:int
Returns:The time as a POSIX timestamp.
class lf.time.FILETIMEToUnixtime
An alias for FILETIMEToPOSIXTime.
class lf.time.POSIXTimeToFILETIME

Converts a POSIX timestamp to a FILETIME timestamp.

classmethod from_int(timestamp)

Converts a POSIX timestamp to a Microsoft Windows FILETIME timestamp.

Parameter:timestamp (int) – The POSIX timestamp.
Return type:int
Returns:The time as a FILETIME timestamp.
class lf.time.UnixTimeToFILETIME
An alias for POSIXTimeToFILETIME.
class lf.time.POSIXTimeTodatetime

Converts a POSIX (unix) timestamp to a datetime.

classmethod from_int(timestamp)

Creates a datetime object from a POSIX (unix) timestamp.

Parameter:timestamp (int) – The timestamp as an integer.
Return type:datetime
Returns:The corresponding datetime object.
class lf.time.UnixTimeTodatetime
An alias for POSIXTimeTodatetime.
class lf.time.FILETIMETodatetime

Converts a FILETIME to a datetime.

classmethod from_stream(stream, offset=None, byte_order=LITTLE_ENDIAN)

Creates a datetime object from a stream.

Parameters:
  • stream (IStream) – A stream that contains the FILETIME structure.
  • offset (int or None) – The start of the FILETIME structure in the stream.
  • byte_order (constant) – The byte order to use (from lf.dtypes)
Raises ValueError:
 

If the FILETIME structure is invalid.

Return type:

datetime

Returns:

The corresponding datetime object.

classmethod from_ctype(ctype)

Creates a datetime object from a ctype.

Parameter:ctype (filetime_le or filetime_be) – A FILETIME object.
Raises ValueError:
 If the FILETIME object is invalid.
Return type:datetime
Returns:The corresponding datetime object.
classmethod from_int(timestamp)

Converts a Microsoft FILETIME timestamp to a datetime object.

Parameter:timestamp (int) – The timestamp as a 64 bit integer.
Raises ValueError:
 If timestamp is an invalid value.
Return type:datetime
Returns:The corresponding datetime object.
class lf.time.DOSDateTimeTodatetime

Converts DOS date and times to a datetime.

classmethod from_ints(dos_date=None, dos_time=None)

Converts DOS date and time values to a datetime.

Parameters:
  • dos_date (int) – An MS-DOS date.
  • dos_time (int) – An MS-DOS time.
Raises ValueError:
 

if both dos_date and dos_time are None.

Return type:

datetime

Returns:

The corresponding datetime object.

class lf.time.VariantTimeTodatetime

Converts variant timestamp (OLE date) to a datetime.

classmethod from_stream(stream, offset=None, byte_order=LITTLE_ENDIAN)

Creates a datetime object from a stream.

Parameters:
  • stream (IStream) – A stream that contains the Variant timestamp.
  • offset (int or None) – The start of the Variant timestamp in the stream.
  • byte_order (constant) – The byte order to use (from lf.dtypes)
Raises ValueError:
 

If the Variant timestamp is invalid.

Return type:

datetime

Returns:

The corresponding datetime object.

classmethod from_float(timestamp)

Converts a Variant timestamp to a datetime.

Parameter:timestamp (float) – The Variant timestamp.
Raises ValueError:
 If timestamp is an invalid value.
Return type:datetime
Returns:The corresponding datetime object.

Previous topic

1.3. lf.dtypes.ctypes — Extract native ctypes types

Next topic

2. Common Microsoft Windows Functionality

This Page