In rails 3 there is distance_of_time_in_words
which works fine, but I would like to tweak its ou开发者_运维知识库tput a bit.
The thing is that if the dates are exactly the same it will say "Less Than a day" I would like it to show "Today" instead.
Is that possible?
I wrote a gem called "date-casually" that monkey-patches the Date class with a "casual" method:
Date.today.casual
#=> 'today'
(Date.today + 1).casual
#=> 'tomorrow'
(Date.today - 1).casual
#=> 'yesterday'
Hope it helps:
http://rubygems.org/gems/date-casually
精彩评论