import time


def chop_midnight( tsecs ):
    """
    Returns the epoch time at midnight for the given day.
    """
    tup = time.localtime( tsecs )
    tup = ( tup[0], tup[1], tup[2], 0, 0, 0, tup[6], tup[7], tup[8] )
    return int( time.mktime( tup ) + 0.5 )