/// <summary> /// Articulates a given TimeSpan with a given accuracy /// </summary> /// <param name="span">The TimeSpan to articulate</param> /// <param name="accuracy">Accuracy Flags</param> public static String Articulate(TimeSpan span, ETemporalGroupFlag accuracy) { // populate a list with temporalgroupings. Each temporal grouping // represents a particular element of the articulation, ordered // according to the temporal duration of each element. List <TemporalGrouping> lGroupingCollection = new List <TemporalGrouping>(4); // foreach possible temporal type (day/hour/minute etc.) foreach (ETemporalGroupFlag lType in _mGroupTypes) { // if the temporal type isn't specified in the accuracy, skip. if ((accuracy & lType) != lType) { continue; } // get the timespan for this temporal type TimeSpan lTimeSpan = TimeSpanAttribute.RetrieveAttribute(lType).GetTimeSpan(); if (span.Ticks >= lTimeSpan.Ticks) { // divide the current timespan with the temporal group span Int32 magnitude = (Int32)(span.Ticks / lTimeSpan.Ticks); lGroupingCollection.Add(new TemporalGrouping(lType, magnitude)); span = new TimeSpan(span.Ticks % lTimeSpan.Ticks); } } return(Textify(lGroupingCollection)); }
public override String ToString() { String result = this.Magnitude.ToString(); result += ValueLib.Space.StringValue + TimeSpanAttribute.RetrieveAttribute(this.Type).Name; if (this.Magnitude > 1) { result += Plural; } return(result); }