Exemplo n.º 1
0
        public string GetIssuingDate(string contents)
        {
            char[]   separators = { ' ', '\t', '\n', '\r' };
            string[] words      = contents.Split(separators);

            DateRecognizer recognizer = DateRecognizer.GetInstance();
            List <string>  foundDates = recognizer.FindItems(contents);

            foundDates = recognizer.RemoveNonValidDates(foundDates);

            int    firstValidDateIndex = 0;
            string foundDate           = "Fecha no detectada"; // DateTime.Today.ToString("dd MMM yyyy");

            while (firstValidDateIndex < foundDates.Count && !ContainsDate(foundDates[firstValidDateIndex]))
            {
                firstValidDateIndex++;
            }

            if (foundDates.Count >= 0 && firstValidDateIndex < foundDates.Count)
            {
                foundDate = foundDates[firstValidDateIndex].Replace(",", "").Trim();
            }

            return(foundDate);
        }
Exemplo n.º 2
0
 public static DateRecognizer GetInstance()
 {
     if (_single == null)
     {
         _single = new DateRecognizer();
     }
     return(_single);
 }