from datetime import datetime


def timestamp_to_milliseconds(obj):
    """Convert an object into a timestamp in milliseconds.

    Parameters
    ----------
    obj
        A :class:`~datetime.datetime` object, an ISO-8601 formatted :class:`str`,
        a :class:`float` in seconds, or an :class:`int` in milliseconds.

    Returns
    -------
    :class:`int`
        The timestamp in milliseconds.
    """
    if isinstance(obj, int):  # in milliseconds
        return obj

    if isinstance(obj, float):  # in seconds
        return round(obj * 1e3)

    if isinstance(obj, str):  # an ISO-8601 string
        string = obj.replace('T', ' ')
        fmt = '%Y-%m-%d %H:%M:%S'
        if '.' in string:
            fmt += '.%f'
        obj = datetime.strptime(string, fmt)

    return round(obj.timestamp() * 1e3)