def get_dayseconds(dt):
    """Returns the number of seconds behind the most recent midnight.

    For example: ``get_dayseconds(datetime(2016, 9, 12, 1, 2, 3)) => 3723``.
    """
    return dt.hour * 3600 + dt.minute * 60 + dt.second