Disco.DateTimeExtensions.RelativeTime C# (CSharp) Method

RelativeTime() private static method

private static RelativeTime ( this difference, bool withoutSuffix ) : string
difference this
withoutSuffix bool
return string
        private static string RelativeTime(this TimeSpan difference, bool withoutSuffix)
        {
            string output;

            if (Math.Round(difference.TotalSeconds) < 45)
                output = "a few seconds";
            else if (Math.Round(difference.TotalMinutes) == 1)
                output = "a minute";
            else if (Math.Round(difference.TotalMinutes) < 45)
                output = (int)Math.Round(difference.TotalMinutes) + " minutes";
            else if (Math.Round(difference.TotalHours) == 1)
                output = "an hour";
            else if (Math.Round(difference.TotalHours) < 22)
                output = (int)Math.Round(difference.TotalHours) + " hours";
            else if (Math.Round(difference.TotalDays) == 1)
                output = "a day";
            else if (Math.Round(difference.TotalDays) <= 25)
                output = (int)Math.Round(difference.TotalDays) + " days";
            else if (Math.Round(difference.TotalDays) <= 45)
                output = "a month";
            else if (Math.Round(difference.TotalDays) < 345)
                output = (int)Math.Round(difference.TotalDays / 30) + " months";
            else if (Math.Round(difference.TotalDays / 365) == 1)
                output = "a year";
            else
                output = (int)Math.Round(difference.TotalDays / 365) + " years";

            if (!withoutSuffix)
                if (difference.TotalMilliseconds > 0)
                    output = "in " + output;
                else
                    output = output + " ago";

            return output;
        }