def _seconds_and_microseconds(timestamp):
    """
    Split a floating point timestamp into an integer number of seconds since
    the epoch, and an integer number of microseconds (having rounded to the
    nearest microsecond).

    If `_seconds_and_microseconds(x) = (y, z)` then the following holds (up to
    the error introduced by floating point operations):

    * `x = y + z / 1_000_000.`
    * `0 <= z < 1_000_000.`
    """

    if isinstance(timestamp, int):
        return (timestamp, 0)
    else:
        timestamp_us = int(round(timestamp * 1e6))
        return divmod(timestamp_us, 1000000)