Ejemplo n.º 1
0
        public static List <Pullenti.Ner.ReferentToken> CreateReferents(DateExToken et)
        {
            if (!et.IsDiap || et.ItemsTo.Count == 0)
            {
                List <Pullenti.Ner.ReferentToken> li = _createRefs(et.ItemsFrom);
                if (li == null || li.Count == 0)
                {
                    return(null);
                }
                return(li);
            }
            List <Pullenti.Ner.ReferentToken> liFr = _createRefs(et.ItemsFrom);
            List <Pullenti.Ner.ReferentToken> liTo = _createRefs(et.ItemsTo);

            Pullenti.Ner.Date.DateRangeReferent ra = new Pullenti.Ner.Date.DateRangeReferent();
            if (liFr.Count > 0)
            {
                ra.DateFrom = liFr[0].Tag as Pullenti.Ner.Date.DateReferent;
            }
            if (liTo.Count > 0)
            {
                ra.DateTo = liTo[0].Tag as Pullenti.Ner.Date.DateReferent;
            }
            List <Pullenti.Ner.ReferentToken> res = new List <Pullenti.Ner.ReferentToken>();

            res.AddRange(liFr);
            res.AddRange(liTo);
            res.Add(new Pullenti.Ner.ReferentToken(ra, et.BeginToken, et.EndToken));
            if (res.Count == 0)
            {
                return(null);
            }
            res[0].Tag = ra;
            return(res);
        }
Ejemplo n.º 2
0
        public static DateTime?CalculateDate(Pullenti.Ner.Date.DateReferent dr, DateTime now, int tense)
        {
            if (dr.Pointer == Pullenti.Ner.Date.DatePointerType.Today)
            {
                return(now);
            }
            if (!dr.IsRelative && dr.Dt != null)
            {
                return(dr.Dt);
            }
            DateExToken det = new DateExToken(null, null);

            det.ItemsFrom = _createDateEx(dr);
            return(det.GetDate(now, tense));
        }
Ejemplo n.º 3
0
        public static bool CalculateDateRange(Pullenti.Ner.Date.DateReferent dr, DateTime now, out DateTime from, out DateTime to, int tense)
        {
            if (dr.Pointer == Pullenti.Ner.Date.DatePointerType.Today)
            {
                from = now;
                to   = now;
                return(true);
            }
            if (!dr.IsRelative && dr.Dt != null)
            {
                from = (to = dr.Dt.Value);
                return(true);
            }
            DateExToken det = new DateExToken(null, null);

            det.ItemsFrom = _createDateEx(dr);
            return(det.GetDates(now, out from, out to, tense));
        }