Beispiel #1
0
        public string BuildText(IRRuleTokenContainer tokenContainer)
        {
            var resultString = BuildFrequency(tokenContainer);


            var freqValue = (FreqToken.FreqValue)tokenContainer.GetFreq().GetValue();

            if (freqValue == FreqToken.FreqValue.WEEKLY)
            {
                resultString += " " + BuildWeeklyDays(tokenContainer);
            }
            else if (freqValue == FreqToken.FreqValue.MONTHLY && tokenContainer.GetByMontDay() != null)
            {
                resultString += " " + BuildMonthlyOnDay(tokenContainer);
            }
            else if (freqValue == FreqToken.FreqValue.MONTHLY && tokenContainer.GetBySetPos() != null &&
                     tokenContainer.GetByDay() != null)
            {
                resultString += " " + BuildMonthlyOnNumberedDay(tokenContainer);
            }
            else if (freqValue == FreqToken.FreqValue.YEARLY && tokenContainer.GetByMonth() != null &&
                     tokenContainer.GetByMontDay() != null)
            {
                resultString += " " + BuildYearlyOnDay(tokenContainer);
            }
            else if (freqValue == FreqToken.FreqValue.YEARLY && tokenContainer.GetByDay() != null &&
                     tokenContainer.GetBySetPos() != null &&
                     tokenContainer.GetByMonth() != null)
            {
                resultString += " " + BuildYearlyOnNumbered(tokenContainer);
            }
            if (tokenContainer.GetStart() != null)
            {
                var ending = _buildStartDate(tokenContainer);
                if (ending != null)
                {
                    resultString += ", " + ending;
                }
            }

            // Endings
            if (tokenContainer.GetUntil() != null)
            {
                var ending = _buildUntilDateEnding(tokenContainer);
                if (ending != null)
                {
                    resultString += ", " + ending;
                }
            }
            else if (tokenContainer.GetCount() != null)
            {
                var ending = BuildCountEnding(tokenContainer);
                if (ending != null)
                {
                    resultString += ", " + ending;
                }
            }

            return(CapitalizeFirstLetter(resultString.Trim()));
        }
        private string _buildStartDate(IRRuleTokenContainer pTokenContainer)
        {
            var startToken = pTokenContainer.GetStart();

            if (startToken == null)
            {
                return(null);
            }
            string result = _fragmentTranslator.GetTranslatedFragment(ETranslationFragment.DTSTART);

            result += $" {_dateFormatting.FormatFullDate(((ValueWrapper)startToken.GetValue()).getLocalDateTime())}";
            return(result);
        }