Example #1
0
		/// <summary>
		/// Use this static method to resolve relative time references and obtain the corresponding
		/// DateTime objects. Example:
		/// <code>
		/// TimeParser pStart = new TimeParser("now-1month"); // starting time
		/// TimeParser pEnd = new TimeParser("start+1week");  // ending time
		/// TimeSpec specStart = pStart.Parse();
		/// TimeSpec specEnd = pEnd.Parse();
		/// DateTime[] gc = TimeSpec.GetTimes(specStart, specEnd);
		/// </code>
		/// </summary>
		/// <param name="spec1">Starting time specification</param>
		/// <param name="spec2">Ending time specification</param>
		/// <returns>Two element array containing DateTime objects</returns>
		public static DateTime[] GetTimes(TimeSpec spec1, TimeSpec spec2)
		{
			if (spec1.Type == TimeSpecType.Start || spec2.Type == TimeSpecType.End)
			{
				throw new RrdException("Recursive time specifications not allowed");
			}
			spec1.context = spec2;
			spec2.context = spec1;
			return new[]
			       	{
			       		spec1.GetTime(),
			       		spec2.GetTime()
			       	};
		}