def _to_epoch_time(date):
 if hasattr(date, 'timestamp'):
  return int(date.timestamp())
 else:
  epoch = datetime.fromtimestamp(0)
  delta = (date - epoch)
  return int(delta.total_seconds())

def _to_epoch_time ( date ) : if hasattr ( date , 'timestamp' ) : return int ( date . timestamp ( ) ) else : epoch = datetime . fromtimestamp ( 0 ) delta = ( date - epoch ) return int ( delta . total_seconds ( ) )
convert a datetime object to an integer number of seconds since the unix epoch .