import time


def date_round_down( tm ):
    """
    Given a date in seconds, this function rounds down to midnight of the
    date.  Returns a date in seconds.
    """
    s = time.strftime( "%Y %m %d", time.localtime( tm ) )
    T = time.strptime( s, "%Y %m %d" )
    return time.mktime( T )