コード例 #1
0
 def _get_date(self, string):
     """
     Converts a string into a datetime object.
     """
     if self.regex:
         string = self._get_substring(string)
     return dateutils.date_from_str(string)
コード例 #2
0
    def get_date(self, data):
        """Return the value of the date field.

        Parameters
        ----------
        data : |dict|
            A document from which to extract the date field.

        Returns
        -------
        |datetime| or |None|
            The value of the date field.

        """
        date = self._get_date_value(data)
        if isinstance(date, datetime.datetime):
            return date
        elif date:
            return date_from_str(str(date), self.date_format)