def METHOD_NAME(obj):
    """Convert a timestamp in seconds to milliseconds.
    If the input overflows, it is treated as milliseconds - otherwise it is
    treated as seconds and converted.
    """
    try:
        datetime.fromtimestamp(obj)
        return int(obj * 1000)
    except (ValueError, OverflowError, OSError):
        return int(obj)