title: Format A TimeSpan With Years
body: <p>I have a class with 2 date properties: <code>FirstDay</code> and <code>LastDay</code>.  <code>LastDay</code> is nullable.  I would like to generate a string in the format of <code>"x year(s) y day(s)"</code>.  If the total years are less than 1, I would like to omit the year section.  If the total days are less than 1, I would like to omit the day section.  If either years or days are 0, they should say "day/year", rather than "days/years" respectively.</p>
  
  <p><strong>Examples:</strong><br/>
  2.2 years:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"2 years 73 days"<br/>
  1.002738 years:&nbsp;&nbsp;&nbsp;"1 year 1 day"<br/>
  0.2 years:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"73 days"<br/>
  2 years:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"2 years"<br/></p>
  
  <p>What I have works, but it is long:</p>
  
  <pre><code>private const decimal DaysInAYear = 365.242M;
  
  public string LengthInYearsAndDays
  {
      get
      {
          var lastDay = this.LastDay ?? DateTime.Today;
          var lengthValue = lastDay - this.FirstDay;
  
          var builder = new StringBuilder();
  
          var totalDays = (decimal)lengthValue.TotalDays;
          var totalYears = totalDays / DaysInAYear;
          var years = (int)Math.Floor(totalYears);
  
          totalDays -= (years * DaysInAYear);
          var days = (int)Math.Floor(totalDays);
  
          Func&lt;int, string&gt; sIfPlural = value =&gt;
              value &gt; 1 ? "s" : string.Empty;
  
          if (years &gt; 0)
          {
              builder.AppendFormat(
                  CultureInfo.InvariantCulture,
                  "{0} year{1}",
                  years,
                  sIfPlural(years));
  
              if (days &gt; 0)
              {
                  builder.Append(" ");
              }
          }
  
          if (days &gt; 0)
          {
              builder.AppendFormat(
                  CultureInfo.InvariantCulture,
                  "{0} day{1}",
                  days,
                  sIfPlural(days));
          }
  
          var length = builder.ToString();
          return length;
      }
  }
  </code></pre>
  
  <p>Is there a more concise way of doing this (but still readable)?</p>