开发者

Distance of time in days

开发者 https://www.devze.com 2023-03-08 06:10 出处:网络
In rails 3 there is distance_of_time_in_words which works fine, but I would like to tweak its ou开发者_运维知识库tput a bit.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消