Last active
October 4, 2017 14:43
-
-
Save gregblass/46003b15a3290ff97f6f to your computer and use it in GitHub Desktop.
A better, Facebook-style activity time_ago_in_words
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def better_time_ago_in_words(date_time) | |
if date_time < 2.days.ago | |
"#{date_time.strftime('%B %e')} at #{date_time.strftime('%l:%M%P')}" | |
elsif date_time < 1.day.ago | |
"Yesterday at #{date_time.strftime('%l:%M%P')}" | |
else | |
time_ago_in_words(date_time) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment