Reputation: 14726
I've found the list of format directives for the strftime
method http://ruby-doc.org/core-2.3.0/Time.html#method-i-strftime
There are various options to format a time like weekdays, day of month... But I'm interested in formating a Time like
Time.parse("2016-02-30T12:24").strftime("%XXX, at %H:%M")
# => tomorrow at 12:24
Here %XXX
should be "today", "yesterday", "tomorrow", "in 2 days" or "in 3 days".
Is it possible to extend the directives of
strftime
so that I can use my own placeholder?
Upvotes: 2
Views: 187
Reputation: 70
You can use Rails Distance of Time in Words which will give you 'about 1 day' but I think it would be easier to use MomentJS's Calendar Time.
Calendar Time will help you return something like " Tomorrow at 2:30 AM"
Upvotes: 1