Pack time value into proper binary format

def prepare(cls, value):
        """Pack time value into proper binary format"""
        pfield = struct.pack('b', cls.type_code)
        if isinstance(value, string_types):
            if "." in value:
                value = datetime.datetime.strptime(value, "%H:%M:%S.%f")
            else:
                value = datetime.datetime.strptime(value, "%H:%M:%S")
        millisecond = value.second * 1000 + value.microsecond // 1000
        hour = value.hour | 0x80    # for some unknown reasons hour has to be bit-or'ed with 0x80
        pfield += cls._struct.pack(hour, value.minute, millisecond)
        return pfield