title: Custom string formats of TimeSpan
body: <p>I want to format TimeSpans in C# in this way:</p>
  
  <p>xxx day(s) yyy hours(s) zzz minute(s)</p>
  
  <p>Conditions:</p>
  
  <ol>
  <li><p>Extra seconds should be truncated</p></li>
  <li><p>day(s) is the largest unit I want. I want 34 days to appear as 34 days rather than 1 month 4 days etc.</p></li>
  <li><p>If timespan is less than one day, I dont want the day part to show up. Likewise if span is less than 1 hour, I want only the mins part to show up.</p></li>
  </ol>
  
  <p>Is there any way I can do this using built-in format strings or there is no way other than writing my own function?  </p>
  
  <p>Edit: Currently using my own function for this. It takes TimeSpan in minutes as input <code>(TimeSpan.TotalMinutes)</code> :</p>
  
  <pre><code>private static string GetTimeStringFromMinutes(double p)
          {
              var minutes = (int) p;
              int hours = minutes / 60;
              minutes = minutes % 60;
              int days = hours/24;
              hours = hours%24;
              string dayPart = days + " day(s) ";
              string hoursPart = hours + " hour(s) ";
              string minutesPart = minutes + " minute(s)";
              if (days != 0)
                  return (dayPart + hoursPart + minutesPart);
              if (hours != 0)
                  return (hoursPart + minutesPart);
              return (minutesPart);
          }
  </code></pre>