} // GetCalendarPeriod #endregion #region Interval // ---------------------------------------------------------------------- public string GetInterval(DateTime start, DateTime end, IntervalEdge startEdge, IntervalEdge endEdge, TimeSpan duration) { if (end < start) { throw new ArgumentOutOfRangeException("end"); } StringBuilder sb = new StringBuilder(); // interval start switch (startEdge) { case IntervalEdge.Closed: sb.Append(IntervalStartClosed); break; case IntervalEdge.Open: sb.Append(UseIsoIntervalNotation ? intervalStartOpenIso : intervalStartOpen); break; } bool addDuration = true; bool startHasTimeOfDay = TimeTool.HasTimeOfDay(start); // no duration - schow start date (optionally with the time part) if (duration == TimeSpec.MinPeriodDuration) { sb.Append(startHasTimeOfDay ? GetDateTime(start) : GetShortDate(start)); addDuration = false; } // within one day: show full start, end time and suration else if (TimeCompare.IsSameDay(start, end)) { sb.Append(GetDateTime(start)); sb.Append(startEndSeparator); sb.Append(GetLongTime(end)); } else { bool endHasTimeOfDay = TimeTool.HasTimeOfDay(start); bool hasTimeOfDays = startHasTimeOfDay || endHasTimeOfDay; if (hasTimeOfDays) { sb.Append(GetDateTime(start)); sb.Append(startEndSeparator); sb.Append(GetDateTime(end)); } else { sb.Append(GetShortDate(start)); sb.Append(startEndSeparator); sb.Append(GetShortDate(end)); } } // interval end switch (endEdge) { case IntervalEdge.Closed: sb.Append(IntervalEndClosed); break; case IntervalEdge.Open: sb.Append(UseIsoIntervalNotation ? IntervalEndOpenIso : IntervalEndOpen); break; } // duration if (addDuration) { sb.Append(durationSeparator); sb.Append(GetDuration(duration)); } return(sb.ToString()); } // GetInterval