Ejemplo n.º 1
0
 public static string GenerateWeekendTimex(DateObject date = default(DateObject))
 {
     if (date.IsDefaultValue())
     {
         return($"{Constants.TimexFuzzyYear}{Constants.DateTimexConnector}{Constants.TimexFuzzyWeek}{Constants.DateTimexConnector}{Constants.TimexWeekend}");
     }
     else
     {
         return($"{FormatUtil.ToIsoWeekTimex(date)}{Constants.DateTimexConnector}{Constants.TimexWeekend}");
     }
 }
Ejemplo n.º 2
0
 public static string GenerateMonthTimex(DateObject date = default(DateObject))
 {
     if (date.IsDefaultValue())
     {
         return($"{Constants.TimexFuzzyYear}{Constants.DateTimexConnector}{Constants.TimexFuzzyMonth}");
     }
     else
     {
         return($"{date.Year:D4}{Constants.DateTimexConnector}{date.Month:D2}");
     }
 }
Ejemplo n.º 3
0
 public static string GenerateWeekTimex(DateObject monday = default(DateObject))
 {
     if (monday.IsDefaultValue())
     {
         return($"{Constants.TimexFuzzyYear}{Constants.DateTimexConnector}{Constants.TimexFuzzyWeek}");
     }
     else
     {
         return(FormatUtil.ToIsoWeekTimex(monday));
     }
 }
Ejemplo n.º 4
0
        public static string GenerateDatePeriodTimex(DateObject begin, DateObject end, DatePeriodTimexType timexType, DateObject alternativeBegin = default(DateObject), DateObject alternativeEnd = default(DateObject))
        {
            var equalDurationLength = ((end - begin) == (alternativeEnd - alternativeBegin));

            if (alternativeBegin.IsDefaultValue() || alternativeEnd.IsDefaultValue())
            {
                equalDurationLength = true;
            }

            var unitCount = "XX";

            if (equalDurationLength)
            {
                switch (timexType)
                {
                case DatePeriodTimexType.ByDay:
                    unitCount = (end - begin).TotalDays.ToString(CultureInfo.InvariantCulture);
                    break;

                case DatePeriodTimexType.ByWeek:
                    unitCount = ((end - begin).TotalDays / 7).ToString(CultureInfo.InvariantCulture);
                    break;

                case DatePeriodTimexType.ByMonth:
                    unitCount = (((end.Year - begin.Year) * 12) + (end.Month - begin.Month)).ToString();
                    break;

                default:
                    unitCount = ((end.Year - begin.Year) + (end.Month - begin.Month) / 12.0).ToString(CultureInfo.InvariantCulture);
                    break;
                }
            }

            var datePeriodTimex = $"P{unitCount}{DatePeriodTimexTypeToTimexSuffix[timexType]}";

            return($"({FormatUtil.LuisDate(begin, alternativeBegin)},{FormatUtil.LuisDate(end, alternativeEnd)},{datePeriodTimex})");
        }
Ejemplo n.º 5
0
 public static string GenerateYearTimex(DateObject date = default(DateObject))
 {
     return(date.IsDefaultValue() ? Constants.TimexFuzzyYear : $"{date.Year:D4}");
 }