I’m completely new to ruby and I’m trying to format the created_at field pulled in from the Twitter gem. I know in rails you can use time_ago_in_words for rails, but I was wondering how you can do this in plain ruby. Infact I’m wondering how you can format a date which is in this format to start with “Mon, 10 Oct 2011 20:13:10 +0000”. Is this the standard date format?
Any help would be brilliant.
If you’re using Ruby 1.9,
Time.parseunderstands your format just fine:In 1.8,
DateTimehas a similar method:If you want to implement distance_of_time_in_words by yourself, the best starting point is probably to check out its source (click the view source link on that page).