Exemple #1
0
def variant_time_to_datetime(vtime):
    """
    Converts a variant time (OLE date/time) to a Python datetime object.

    :parameters:
        vtime
            The time in OLE date format.

    :raises:
        ValueError
            If vtime is an invalid value.

    :rtype: datetime
    :returns: The time as a Python datetime object.
    """
    return VariantTimeTodatetime.from_float(vtime)
Exemple #2
0
def variant_time_to_datetime(vtime):
    """
    Converts a variant time (OLE date/time) to a Python datetime object.

    :parameters:
        vtime
            The time in OLE date format.

    :raises:
        ValueError
            If vtime is an invalid value.

    :rtype: datetime
    :returns: The time as a Python datetime object.
    """
    return VariantTimeTodatetime.from_float(vtime)
Exemple #3
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
Exemple #4
0
    def test_from_float(self):
        ae = self.assertEqual

        value = VariantTimeTodatetime.from_float(3.25)
        ae(value, datetime(1900, 1, 2, 6, 0, 0))
Exemple #5
0
    def test_from_float(self):
        ae = self.assertEqual

        value = VariantTimeTodatetime.from_float(3.25)
        ae(value, datetime(1900, 1, 2, 6, 0, 0))