ruby on rails
I have a number of products that are perishable. Therefore, each product has an attribute called hours_expiration that tells how many hours the product can be used before it goes bad.
For ex, apple expires in 168 hours; nut expires in 4320 hours.
Given, the product's hours-to-expiration and the current time (Time.now or Date.now), how can I humanize the time-to-expiration in some of the following sample ways?
Your item is set to expire in about:
Looking for something robust and simple!
Helper distance_of_time_in_words
seems to be what you ask for.
http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-distance_of_time_in_words
查看时间距离文档:http://apidock.com/rails/ActionView/Helpers/DateHelper/distance_of_time_in_words
链接地址: http://www.djcxy.com/p/95412.html上一篇: 在特定时间范围内查找时间的发生和持续时间
下一篇: 红宝石在轨道上