private DateTimeResolutionResult MergeDateAndTimePeriod(string text, DateObject referenceTime) { var ret = new DateTimeResolutionResult(); var er1 = this.config.DateExtractor.Extract(text, referenceTime); var er2 = this.config.TimePeriodExtractor.Extract(text, referenceTime); if (er1.Count != 1 || er2.Count != 1) { return(ret); } var pr1 = this.config.DateParser.Parse(er1[0], referenceTime); var pr2 = this.config.TimePeriodParser.Parse(er2[0], referenceTime); var timeRange = (Tuple <DateObject, DateObject>)((DateTimeResolutionResult)pr2.Value).FutureValue; var beginTime = timeRange.Item1; var endTime = timeRange.Item2; var futureDate = (DateObject)((DateTimeResolutionResult)pr1.Value).FutureValue; var pastDate = (DateObject)((DateTimeResolutionResult)pr1.Value).PastValue; // handle cases with time like 25時 which resolve to the next day var swiftDay = 0; var timexHours = TimexUtility.ParseHoursFromTimePeriodTimex(pr2.TimexStr); if (timexHours.Item1 > Constants.DayHourCount) { pastDate = pastDate.AddDays(1); futureDate = futureDate.AddDays(1); } else if (timexHours.Item2 > Constants.DayHourCount) { swiftDay++; } var pastDateAlt = pastDate.AddDays(swiftDay); var futureDateAlt = futureDate.AddDays(swiftDay); ret.FutureValue = new Tuple <DateObject, DateObject>( DateObject.MinValue.SafeCreateFromValue(futureDate.Year, futureDate.Month, futureDate.Day, beginTime.Hour, beginTime.Minute, beginTime.Second), DateObject.MinValue.SafeCreateFromValue(futureDateAlt.Year, futureDateAlt.Month, futureDateAlt.Day, endTime.Hour, endTime.Minute, endTime.Second)); ret.PastValue = new Tuple <DateObject, DateObject>( DateObject.MinValue.SafeCreateFromValue(pastDate.Year, pastDate.Month, pastDate.Day, beginTime.Hour, beginTime.Minute, beginTime.Second), DateObject.MinValue.SafeCreateFromValue(pastDateAlt.Year, pastDateAlt.Month, pastDateAlt.Day, endTime.Hour, endTime.Minute, endTime.Second)); ret.Timex = TimexUtility.GenerateSplitDateTimePeriodTimex(pr1.TimexStr, pr2.TimexStr); ret.Success = !string.IsNullOrEmpty(ret.Timex); return(ret); }