Disco.DateTimeExtensions.Humanize C# (CSharp) Method

Humanize() public static method

public static Humanize ( this duration, bool withSuffix ) : string
duration this
withSuffix bool
return string
        public static string Humanize(this TimeSpan duration, bool withSuffix)
        {
            string output = RelativeTime(duration.Ticks > 0 ? duration : duration.Negate(), true);

            if (withSuffix)
                if (duration.TotalMilliseconds > 0)
                    output = "in " + output;
                else
                    output = output + " ago";

            return output;
        }