from typing import Any


def serialize_timestamp(val: Any) -> str:
    """
    Serialize a value to a UNIX timestamp.

    If the object has a 'timestamp' method, call that method
    to obtain the timestamp.

    Otherwise, assume the value is already a timestamp.
    """
    try:
        return val.timestamp()
    except AttributeError:
        return str(val)