コード例 #1
0
ファイル: time.py プロジェクト: pombreda/libforensics
    def test_from_ints(self):
        ae = self.assertEqual
        ar = self.assertRaises

        value = DOSDateTimeTodatetime.from_ints(0x2D7A, 0x9B20)
        ae(value, datetime(2002, 11, 26, 19, 25, 0))

        value = DOSDateTimeTodatetime.from_ints(dos_time=0x9B20)
        ae(value, datetime(1, 1, 1, 19, 25, 0))

        value = DOSDateTimeTodatetime.from_ints(0x2D7A)
        ae(value, datetime(2002, 11, 26, 0, 0, 0))

        ar(ValueError, DOSDateTimeTodatetime.from_ints)
コード例 #2
0
ファイル: time.py プロジェクト: KrestMoraes/libforensics
    def test_from_ints(self):
        ae = self.assertEqual
        ar = self.assertRaises

        value = DOSDateTimeTodatetime.from_ints(0x2D7A, 0x9B20)
        ae(value, datetime(2002, 11, 26, 19, 25, 0))

        value = DOSDateTimeTodatetime.from_ints(dos_time=0x9B20)
        ae(value, datetime(1, 1, 1, 19, 25, 0))

        value = DOSDateTimeTodatetime.from_ints(0x2D7A)
        ae(value, datetime(2002, 11, 26, 0, 0, 0))

        ar(ValueError, DOSDateTimeTodatetime.from_ints)
コード例 #3
0
def dos_time_to_time(dos_time):
    """
    Converts an MS-DOS time stamp into a Python datetime.time object.

    :parameters:
        dos_time
            An MS-DOS time stamp.

    :rtype: time
    :returns The date in a datetime.time object.
    """

    return DOSDateTimeTodatetime.from_ints(dos_time=dos_time).time()
コード例 #4
0
def dos_date_to_date(dos_date):
    """
    Converts an MS-DOS date stamp into a Python datetime.date object.

    :parameters:
        dos_date
            An MS-DOS date stamp.

    :rtype: date
    :returns: The date in a datetime.date object.
    """

    return DOSDateTimeTodatetime.from_ints(dos_date).date()
コード例 #5
0
ファイル: time.py プロジェクト: KrestMoraes/libforensics
def dos_time_to_time(dos_time):
    """
    Converts an MS-DOS time stamp into a Python datetime.time object.

    :parameters:
        dos_time
            An MS-DOS time stamp.

    :rtype: time
    :returns The date in a datetime.time object.
    """

    return DOSDateTimeTodatetime.from_ints(dos_time=dos_time).time()
コード例 #6
0
ファイル: time.py プロジェクト: KrestMoraes/libforensics
def dos_date_to_date(dos_date):
    """
    Converts an MS-DOS date stamp into a Python datetime.date object.

    :parameters:
        dos_date
            An MS-DOS date stamp.

    :rtype: date
    :returns: The date in a datetime.date object.
    """

    return DOSDateTimeTodatetime.from_ints(dos_date).date()
コード例 #7
0
def convert_timestamp(timestamp, timestamp_type):
    """Converts a timestamp from an integer into a datetime object."""

    if timestamp_type == "posix":
        new_timestamp = POSIXTimeTodatetime.from_int(timestamp)

    elif timestamp_type == "dosdate":
        new_timestamp = DOSDateTimeTodatetime.from_ints(timestamp, None).date()

    elif timestamp_type == "dostime":
        new_timestamp = DOSDateTimeTodatetime.from_ints(None, timestamp).time()

    elif timestamp_type == "filetime":
        new_timestamp = FILETIMETodatetime.from_int(timestamp)

    elif timestamp_type == "variant":
        new_timestamp = VariantTimeTodatetime.from_float(timestamp)

    else:
        raise ValueError("Unknown timestamp type: {0}".format(timestamp_type))
    # end if

    return new_timestamp
コード例 #8
0
def dos_date_time_to_datetime(dos_date, dos_time):
    """
    Converts an MS-DOS date and time stamps into a Python datetime object.

    :parameters:
        dos_date
            An MS-DOS date.

        dos_time
            An MS-DOS time.

    :rtype: datetime
    :returns: The date and time.
    """
    return DOSDateTimeTodatetime.from_ints(dos_date, dos_time)
コード例 #9
0
ファイル: time.py プロジェクト: KrestMoraes/libforensics
def dos_date_time_to_datetime(dos_date, dos_time):
    """
    Converts an MS-DOS date and time stamps into a Python datetime object.

    :parameters:
        dos_date
            An MS-DOS date.

        dos_time
            An MS-DOS time.

    :rtype: datetime
    :returns: The date and time.
    """
    return DOSDateTimeTodatetime.from_ints(dos_date, dos_time)