Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/git-bro/core_extensions.rb
Instance Method Summary collapse
Instance Method Details
#relative_to(time) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/git-bro/core_extensions.rb', line 2 def relative_to(time) diff = time - self return "#{diff.to_i} seconds ago" if diff < 60 return "#{(diff/60).to_i} minutes ago" if diff < 3600 return "#{(diff/3600).to_i} hours ago" if diff < 86400 return "#{(diff/86400).to_i} days ago" if diff < 604800 self.strftime("%B %d, %Y") end |