Tatham Oddie

Released: RelativeTime

with 2 comments

Ruby has a nifty little function called time_ago_in_words. You pass it an arbitrary number of seconds and it gives you back something friendly like “about 2 weeks ago”.

Today, I implemented a similar routine for .NET.

relativetime.codeplex.com

nuget.org/List/Packages/relativetime

To use it, just include the namespace, then call ToHumanTime() on a TimeSpan object.

If you want more of an idea of what it generates, take a look at the test suite.

Written by Tatham Oddie

March 12, 2011 at 17:46

2 Responses

Subscribe to comments with RSS.

  1. [...] You might also notice why I recently built relativetime and [...]

  2. That’s a great one, Tatham
    Thanks a lot for the library and mention of the other service. Checking both…

    I had the same problem early 2010, and used another similar service, http://www.purl.org

    It gave me URLs like:
    http://purl.org/net/spiurl/meligy

    But was always feeling a bit worried about using a random free service like this. The good thing is I never caught it falling, but you never know what’s coming…

    Mohamed Meligy

    March 19, 2011 at 15:22


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.