def decode_date(self, val):
    """Tries to decode strings that look like dates into datetime objects."""
    if isinstance(val, basestring) and val.count('-') == 2 and len(val) > 9:
      try:
        dt = dateutil.parser.parse(val)
        # Check for UTC.
        if val.endswith(('+00:00', '-00:00', 'Z')):
          # Then remove tzinfo for gae, which is offset-naive.
          dt = dt.replace(tzinfo=None)
        return dt
      except (TypeError, ValueError):
        pass
    return val
Tries to decode strings that look like dates into datetime objects.