一般时间抽取，即年月日分别出现

        Keyword arguments:
        string              -- 含有时间的文本，str类型
329930
def common_time_extrator(self, string):
        

        try:
            if not self.year_check:
                str_year = int(re.search('(\d{4})年', string).group(1))
                check_year = datetime.datetime.now().year
                if str_year in range(1970, check_year + 1):
                    self.year = str_year
                    self.year_check = True
        except:
            pass
        try:
            if not self.month_check:
                str_month = int(re.search('(\d{1,2})月', string).group(1))
                if str_month in range(1, 13):
                    self.month = str_month
                    self.month_check = True
        except:
            pass
        try:
            if not self.day_check:
                str_day = int(re.search('(\d{1,2})[日号]', string).group(1))
                if str_day in range(1, 32):
                    self.day = str_day
                    self.day_check = True
        except:
            pass
751082
def _build_str_from_chinese(chinese_items):
    
    year, month, day = chinese_items
    year = reduce(lambda a, b: a*10+b, map(CHINESE_NUMS.find, year))
    return '%04d-%02d-%02d 00:00:00' % (year, _parse_chinese_field(month), _parse_chinese_field(day))
374045
def get_string(string):
   
   truestring = string
   if string is not None:
      if '/' in string:
         if os.path.isfile(string):
            try:
               with open_(string,'r') as f:
                  truestring = ' '.join(line.strip() for line in f)
            except: pass
      if truestring.strip() == '': truestring = None
   return truestring
322666
def parse(cls, s):
        
        try:
            numbers = map(int, s.split("-"))
        except (ValueError, AttributeError):
            raise ValueError("Date string must be in format YYYY-MM-DD")
        else:
            numbers = list(numbers)
            if len(numbers) == 3:
                return cls(*numbers)
            raise ValueError("Date string must be in format YYYY-MM-DD")
816252
def string(self, *args, **kwargs):
        
        compare = String(*args, **kwargs)
        self.add(compare)

        return self
296581
def get_month_from_date_str(date_str, lang=DEFAULT_DATE_LANG):
    
    date_str = date_str.lower()
    with calendar.different_locale(LOCALES[lang]):
        month_abbrs = list(calendar.month_abbr)
        for seq, abbr in enumerate(month_abbrs):
            if abbr and abbr.lower() in date_str:
                return seq, abbr
    return ()
551648
def from_str(string):
        
        match = re.match(r'^ADD (\w+)$', string)
        if match:
            return AddEvent(match.group(1))
        else:
            raise EventParseError
720836
def create_string(self, value: str) -> String:
        
        self.append((
            8,
            self.create_utf8(value).index
        ))
        return self.get(self.raw_count - 1)
666490
def _read_date_from_string(str1):
    
    full_date = [int(x) for x in str1.split('/')]
    return datetime.date(full_date[0], full_date[1], full_date[2])
828962
public String convertString(String string)
    {
        if (string != null)
        {
            int startTag = string.indexOf('<');
            int endTag = string.indexOf('>');
            if (startTag > -1)
                if (endTag > startTag)
            {
                String tag = string.substring(startTag + 1, endTag);
                boolean bDateField = tag.toUpperCase().contains("DATE");
                if (eomFields != null)
                {
                    for (String token : eomFields)
                    {
                        if (tag.equals(token))
                            bDateField = true;
                    }
                }
                if (bDateField)
                {
                    int endData = string.indexOf('<', endTag);
                    if (endData != -1)
                    {
                        String dateString = string.substring(endTag + 1, endData);
                        Date date = new Date();
                        int type = this.parseDate(dateString, date);
                        if (type != 0)
                        {
                            Calendar calendar = Calendar.getInstance();
                            calendar.setTime(date);
                            if (yearOffset != 0)
                            {
                                calendar.add(Calendar.YEAR, yearOffset);                                
                            }
                            int day = 0;
                            if (monthOffset != 0)
                            {
                                calendar.add(Calendar.DAY_OF_MONTH, 1);
                                day = calendar.get(Calendar.DAY_OF_MONTH);  // Just want to see if this was the end of the month
                                calendar.add(Calendar.DAY_OF_MONTH, -1);     // Restore original date
                                calendar.add(Calendar.MONTH, monthOffset);  // Add the month offset
                                if (eomFields != null)
                                {
                                    for (String token : eomFields)
                                    {
                                        if (tag.equals(token))
                                        {
                                            if (day == 1)
                                            {   // end of (next) month
                                                calendar.add(Calendar.DAY_OF_MONTH, 5);     // next month
                                                calendar.set(Calendar.DAY_OF_MONTH, 1);     // First of next month
                                                calendar.add(Calendar.DAY_OF_MONTH, -1);    // End of month
                                            }
                                        }
                                    }
                                }
                            }
                            if (dayOffset != 0)
                            {
                                calendar.add(Calendar.DAY_OF_MONTH, dayOffset);                                
                            }
                            date = calendar.getTime();
                            
                            String newDateString = this.formatDate(date, type);
                            if (newDateString != null)
                                string = string.substring(0, endTag + 1) + newDateString + string.substring(endData);
                        }
                    }
                }
            }
        }
        return super.convertString(string);
    }
607700
def parseDate(dateString, strict=True):
    
    if (not strict) and (not dateString):
        return None

    if not isinstance(dateString, basestring):
        raise TypeError('%r is not a string' % dateString)

    return parser.parse(dateString)
917826
def stringToDate(fmt="%Y-%m-%d"):
    """"""
    import time
    import datetime
    def conv_func(s):
        return datetime.date(*time.strptime(s,fmt)[:3])
    return conv_func
1372767
def default_parse(self, string):
        
        results = list()
        while(string):
            token = self.longest(string)
            results.append(token)
            string = string[len(token):]
        return results
939372
def strptime(string, timezone=0):
    """"""
    year = int(string[0:4])
    month = int(string[5:7])
    day = int(string[8:10])
    hour = int(string[-5:-3])
    minute = int(string[-2:])
    ts = datetime.datetime(year, month, day) + \
        datetime.timedelta(hours=hour, minutes=minute) - \
        datetime.timedelta(hours=timezone)
    return ts
318123
def from_str(string):
        
        match = re.match(r'^START READING (\w+) FROM \w+ (\d+)$', string)
        if match:
            return SetReadingEvent(match.group(1), int(match.group(2)))
        else:
            raise EventParseError
770779
def date_key(cls, month_string):
		
		month, year = month_string.split(',')
		month_ord = cls.month_ordinal[month]
		return year, month_ord
884496
def _string2Duration(text):
    
    if text == "" or text == "zero":
        return ZERO

    amount, interval = re.match(r"([\d\.]*)(.*)", text).groups()
    amount = int(amount) if amount else 1

    if MILLI_VALUES[interval] == None:
        from mo_logs import Log
        Log.error(
            "{{interval|quote}} in {{text|quote}} is not a recognized duration type (did you use the pural form by mistake?",
            interval=interval,
            text=text
        )

    output = Duration(0)
    if MONTH_VALUES[interval] == 0:
        output.milli = amount * MILLI_VALUES[interval]
    else:
        output.milli = amount * MONTH_VALUES[interval] * MILLI_VALUES.month
        output.month = amount * MONTH_VALUES[interval]

    return output