def midnight(arg=None):
    if arg:
        _arg = parse(arg)
        if isinstance(_arg, datetime.date):
            return datetime.datetime.combine(_arg, datetime.datetime.min.time())
        elif isinstance(_arg, datetime.datetime):
            return datetime.datetime.combine(_arg.date(), datetime.datetime.min.time())
    else:
        return datetime.datetime.combine(_date, datetime.datetime.min.time())
convert date to datetime as midnight or get current day's midnight
dataset/ETHPy150Open shinux/PyTime/pytime/pytime.py/midnight