code: def get_date(context, value):
      
      if not value:
          return None
      if isinstance(value, DateTime):
          return value
      if isinstance(value, datetime):
          return dt2DT(value)
      if not isinstance(value, basestring):
          return None
  
      def try_parse(date_string, format):
          if not format:
              return None
          try:
              struct_time = strptime(date_string, format)
              return datetime(*struct_time[:6])
          except ValueError:
              pass
          return None
  
      def get_locale_format(key, context):
          format = context.translate(key, domain="senaite.core", mapping={})
          # TODO: Is this replacement below strictly necessary?
          return format.replace(r"${", '%').replace('}', '')
  
      # Try with prioritized formats
      formats = [get_locale_format("date_format_long", context),
                 get_locale_format("date_format_short", context),
                 "%Y-%m-%d %H:%M", "%Y-%m-%d", "%Y-%m-%d %H:%M:%S"]
      for pri_format in formats:
          val = try_parse(value, pri_format)
          if not val:
              continue
          val = dt2DT(val)
          if val.timezoneNaive():
              # Use local timezone for tz naive strings
              # see http://dev.plone.org/plone/ticket/10141
              zone = val.localZone(safelocaltime(val.timeTime()))
              parts = val.parts()[:-1] + (zone,)
              val = DateTime(*parts)
          return val
  
      logger.warn("Unable to convert {} to datetime".format(value))
      return None
docs: Tries to return a DateTime.DateTime object