Ejemplo n.º 1
0
        private Nth GetNth(string input)
        {
            if (string.IsNullOrEmpty(input))
            {
                return(null);
            }
            string ntype = input.ToLower().Replace("/", " ");

            ntype = ntype.Replace("\\", " ");
            ntype = ntype.Replace("+", " ");
            ntype = ntype.Replace("n", " ");
            ntype = ntype.Replace("x", " ");
            ntype = ntype.Replace("(", " ");
            ntype = ntype.Replace(")", " ");

            int index = ntype.IndexOf(" ");

            string begin = null;
            string end   = null;

            if (index > -1)
            {
                begin = ntype.Substring(0, index);
                end   = ntype.Substring(index);
            }

            if (string.IsNullOrWhiteSpace(begin))
            {
                return(null);
            }

            Nth result = new Nth();

            int beginint = 0;

            if (!int.TryParse(begin.Trim(), out beginint))
            {
                return(null);
            }

            result.N = beginint;

            int thint = 0;

            if (!string.IsNullOrWhiteSpace(end))
            {
                int.TryParse(end.Trim(), out thint);
                result.Th = thint;
            }
            return(result);
        }
Ejemplo n.º 2
0
 public override string GetDescription()
 {
     return("{0} {1} of the month".Fmt(Nth.ToOrdinalString(), ReferencedRule));
 }