Method: Time#time_ago
- Defined in:
- lib/doing/time.rb
#time_ago ⇒ String
Format date as "X hours ago"
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/doing/time.rb', line 53 def time_ago if self > Date.today.to_time output = humanize(Time.now - self) "#{output} ago" elsif self > (Date.today - 1).to_time "Yesterday at #{strftime('%_I:%M:%S%P')}" elsif self > (Date.today - 6).to_time strftime('%a %I:%M:%S%P') elsif self.year == Date.today.year strftime('%m/%d %I:%M:%S%P') else strftime('%m/%d/%Y %I:%M:%S%P') end end |