def _ensure_datetime_tzinfo(datetime, tzinfo=None):
 if (datetime.tzinfo is None):
  datetime = datetime.replace(tzinfo=UTC)
 if (tzinfo is not None):
  datetime = datetime.astimezone(get_timezone(tzinfo))
  if hasattr(tzinfo, 'normalize'):
   datetime = tzinfo.normalize(datetime)
 return datetime

def _ensure_datetime_tzinfo ( datetime , tzinfo = None ) : if ( datetime . tzinfo is None ) : datetime = datetime . replace ( tzinfo = UTC ) if ( tzinfo is not None ) : datetime = datetime . astimezone ( get_timezone ( tzinfo ) ) if hasattr ( tzinfo , 'normalize' ) : datetime = tzinfo . normalize ( datetime ) return datetime
ensure the datetime passed has an attached tzinfo .