System.TimeUtils.ToHuman C# (CSharp) Method

ToHuman() public static method

Outputs the 'human friendly' format (ex: 4 days ago). English only
public static ToHuman ( this time ) : string
time this
return string
        public static string ToHuman(this TimeSpan time)
        {
            if (time.TotalDays>=365)
            {
                return Math.Round(time.TotalDays/356).ToString()+" years ago";
            }
            if (time.TotalDays>=30)
            {
                return Math.Round(time.TotalDays/30).ToString()+ " months ago";
            }

            if (time.TotalDays>7)
            {
                return Math.Round(time.TotalDays/7).ToString() + " weeks ago";
            }
            if (time.TotalDays>=1)
            {
                return time.Days.ToString() + " days ago";
            }

            if (time.TotalHours>=1)
            {
                return time.Hours.ToString() + " hours ago";
            }

            if (time.TotalMinutes>=1)
            {
                return time.Minutes.ToString() + " minutes ago";
            }
            return "few seconds ago";
        }