Consider the following 2 scenarios: Scenario 1). Today is May 1st 2012, and Scenario 2). Today is September 1st 2012.
Now, consider that we write on our webpage the
Here's how to add some extension methods for this with C# using mean values:
public static class TimeSpanExtensions
{
public static int GetYears(this TimeSpan timespan)
{
return (int)(timespan.Days/365.2425);
}
public static int GetMonths(this TimeSpan timespan)
{
return (int)(timespan.Days/30.436875);
}
}