def _datestamp_to_datetime(datetime_):
 if isinstance(datetime_, basestring):
  try:
   datetime_ = date_str_to_datetime(datetime_)
  except TypeError:
   return None
  except ValueError:
   return None
 if (not isinstance(datetime_, datetime.datetime)):
  return None
 if (datetime_.tzinfo is not None):
  return datetime_
 datetime_ = datetime_.replace(tzinfo=pytz.utc)
 datetime_ = datetime_.astimezone(get_display_timezone())
 return datetime_

def _datestamp_to_datetime ( datetime_ ) : if isinstance ( datetime_ , basestring ) : try : datetime_ = date_str_to_datetime ( datetime_ ) except TypeError : return None except ValueError : return None if ( not isinstance ( datetime_ , datetime . datetime ) ) : return None if ( datetime_ . tzinfo is not None ) : return datetime_ datetime_ = datetime_ . replace ( tzinfo = pytz . utc ) datetime_ = datetime_ . astimezone ( get_display_timezone ( ) ) return datetime_
converts a datestamp to a datetime .