TimeDiff

edit

TimeDiff

Namespace

Summary== Displays the difference in time between the two dates. Return example is "12 years 4 months 24 days 8 hours 33 minutes 5 seconds ==Example==string output=Post.PublishedDate.TimeDiff(DateTime.Now); ==Unit Test

public void TimeDiffShouldSay3Days8Hourse5Minutes3SecondsAgoWhenDateTimeNowIsDiffedWithAddedValues() { var today = DateTime.Now; var then = DateTime.Now.AddDays(3).AddHours(8).AddMinutes(5).AddSeconds(2); var diff = today.TimeDiff(then); Assert.Equal("3 days 8 hours 5 minutes 2 seconds ", diff); }

Comments

SubSonic 3.0 implements this as an extension on System.DateTime - 2.x uses a static method on SubSonic.Sugar.Dates.