现在我有一个函数 time_since
def time_since
seconds = Time.now - self.updated_at
if seconds < 15
display = "Just Now"
elsif seconds < 59.5 #less than 59.5 seconds
display = seconds.round(0).to_s + "s"
elsif seconds < (3600-30) #less than 59.5 minutes
display = (seconds/60).round(0).to_s + "m"
elsif seconds < (86400-1800) #less than 23.5 hours
display = (seconds/3600).round(0).to_s + "h"
elsif seconds < 86400*2 #less than 2 days
display = "Yesterday"
elsif seconds < 86400*7 #less than 1 week
display = self.updated_at.strftime("%A")
else #more than 1 week
mon = self.updated_at.month
day = self.updated_at.day.to_s
display = day + convert_month_number_to_month_name(mon).to_s
end
return display
end
我希望能够将鼠标悬停在它上面并让它显示确切的 updated_at 时间戳。有没有我可以轻松使用的宝石来做到这一点?