CalculateDateRangeFromDelimitedValues() public static method

Calculates the date range from delimited values in format SlidingDateRangeType|Number|TimeUnitType|StartDate|EndDate NOTE: The Displayed End Date is one day before the actual end date. So, if your date range is displayed as 1/3/2015 to 1/4/2015, this will return 1/5/2015 12:00 AM as the End Date
public static CalculateDateRangeFromDelimitedValues ( string value ) : DateRange
value string The value.
return DateRange
        /// <summary>
        /// Formats the delimited values as a phrase such as "Last 14 Days"
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public static string FormatDelimitedValues(string value)
        {
            string[] splitValues = (value ?? string.Empty).Split('|');
            string   result      = string.Empty;

            if (splitValues.Length == 5)
            {
                var    slidingDateRangeMode = splitValues[0].ConvertToEnum <SlidingDateRangeType>();
                var    numberOfTimeUnits    = splitValues[1].AsIntegerOrNull() ?? 1;
                var    timeUnitType         = splitValues[2].ConvertToEnumOrNull <TimeUnitType>();
                string timeUnitText         = timeUnitType != null?timeUnitType.ConvertToString().PluralizeIf(numberOfTimeUnits != 1) : null;

                var start = splitValues[3].AsDateTime();
                var end   = splitValues[4].AsDateTime();
                if (slidingDateRangeMode == SlidingDateRangeType.Current)
                {
                    return(string.Format("{0} {1}", slidingDateRangeMode.ConvertToString(), timeUnitText));
                }
                else if ((SlidingDateRangeType.Last | SlidingDateRangeType.Previous | SlidingDateRangeType.Next | SlidingDateRangeType.Upcoming).HasFlag(slidingDateRangeMode))
                {
                    return(string.Format("{0} {1} {2}", slidingDateRangeMode.ConvertToString(), numberOfTimeUnits, timeUnitText));
                }
                else
                {
                    // DateRange
                    var dateRange = SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues(value);
                    return(dateRange.ToStringAutomatic());
                }
            }

            return(result);
        }
        /// <summary>
        /// Gets the help HTML that explains usage of the SlidingDateRange picker with examples
        /// </summary>
        /// <param name="currentDateTime">The current date time.</param>
        /// <returns></returns>
        public static string GetHelpHtml(DateTime currentDateTime)
        {
            SlidingDateRangePicker helperPicker = new SlidingDateRangePicker();

            SlidingDateRangeType[] slidingDateRangeTypesForHelp = new SlidingDateRangeType[] { SlidingDateRangeType.Current, SlidingDateRangeType.Previous, SlidingDateRangeType.Last, SlidingDateRangeType.Next, SlidingDateRangeType.Upcoming };

            string helpHtml = @"
    
    <div class='slidingdaterange-help'>

        <p>A date range can either be a specific date range, or a sliding date range based on the current date and time.</p>
        <p>For a sliding date range, you can choose either <strong>current, previous, last, next, upcoming</strong> with a time period of <strong>hour, day, week, month, or year</strong>. Note that a week is Monday thru Sunday.</p>
        <br />
        <ul class=''>
            <li><strong>Current</strong> - the time period that the current date/time is in</li>
            <li><strong>Previous</strong> - the time period(s) prior to the current period (does not include the current time period). For example, to see the most recent weekend, select 'Previous 1 Week'</li>
            <li><strong>Last</strong> - the last X time period(s) including the current until today. For example, to see so far this current week and prior week, select 'Last 2 weeks'</li>
            <li><strong>Next</strong> - the next X time period(s) including the rest of the current period. For example, to see the rest of the current month and the next full month after, select 'Next 2 months'</li>
            <li><strong>Upcoming</strong> - the upcoming X time period(s) not including the current time period.</li>
        </ul>

        <h3>Preview of the sliding date ranges</h3>";

            foreach (var slidingDateRangeType in slidingDateRangeTypesForHelp)
            {
                helperPicker.SlidingDateRangeMode = slidingDateRangeType;
                helperPicker.NumberOfTimeUnits    = 2;
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(@"<h4>{0}</h4>", slidingDateRangeType.ConvertToString());
                sb.AppendLine("<ul>");
                foreach (var timeUnitType in Enum.GetValues(typeof(TimeUnitType)).OfType <TimeUnitType>())
                {
                    helperPicker.TimeUnit = timeUnitType;
                    sb.AppendFormat(@"
                    <li>
                        <span class='slidingdaterange-help-key'>{0} {1}</span>
                        <span class='slidingdaterange-help-value'> - {2}</span>
                    </li>",
                                    slidingDateRangeType != SlidingDateRangeType.Current ? helperPicker.NumberOfTimeUnits.ToString() : string.Empty,
                                    helperPicker.TimeUnit.ConvertToString().PluralizeIf(slidingDateRangeType != SlidingDateRangeType.Current && helperPicker.NumberOfTimeUnits > 1),
                                    SlidingDateRangePicker.CalculateDateRangeFromDelimitedValues(helperPicker.DelimitedValues).ToStringAutomatic());
                }
                sb.AppendLine("</ul>");

                helpHtml += sb.ToString();
            }

            helpHtml += @"
    </div>
";

            return(helpHtml);
        }