#NEWLINE# def new_datetime( d ) : #NEWLINE# #INDENT# '\n    Generate a safe datetime from a datetime.date or datetime.datetime object.\n    ' #NEWLINE# kw = [ d . year , d . month , d . day ] #NEWLINE# if isinstance ( d , real_datetime ) : #NEWLINE# #INDENT# kw . extend ( [ d . hour , d . minute , d . second , d . microsecond , d . tzinfo ] ) #NEWLINE# #UNINDENT# return datetime ( * kw )