Exemple #1
0
        private DateTimeResolutionResult ParseRelativeUnit(string text, DateObject referenceTime)
        {
            var ret = new DateTimeResolutionResult();

            var match = this.config.RestOfDateRegex.Match(text);

            if (match.Success)
            {
                var srcUnit = match.Groups[Constants.UnitGroupName].Value;

                var unitStr = config.UnitMap[srcUnit];

                int        swiftValue = 1;
                DateObject beginTime;
                var        endTime = beginTime = referenceTime;

                if (config.UnitMap.ContainsKey(srcUnit))
                {
                    ret.Timex = TimexUtility.GenerateRelativeUnitDateTimePeriodTimex(ref beginTime, ref endTime, referenceTime, unitStr, swiftValue);

                    ret.FutureValue = ret.PastValue = new Tuple <DateObject, DateObject>(beginTime, endTime);
                    ret.Success     = !string.IsNullOrEmpty(ret.Timex);

                    return(ret);
                }
            }

            return(ret);
        }