7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/tkh_toolbox/tkh_toolbox_helper.rb', line 7
def human_date_and_time(dt)
now = Time.zone.now
if now.to_i - dt.to_i <= 15 'just now'
elsif now.to_i - dt.to_i < ( 60 * 5 ) 'a few minutes ago'
elsif dt > Time.zone.now.beginning_of_day "at #{ dt.strftime('%I:%M %P')}"
elsif dt > Time.zone.now.beginning_of_day - 24.hours "yesterday at #{ dt.strftime('%I:%M %P')}"
elsif dt > Time.zone.now.beginning_of_week dt.strftime('%A at %I:%M %P')
elsif dt > Time.zone.now.beginning_of_year dt.strftime("%b. %e at %I:%M %P")
else dt.strftime("%b. %e, %Y")
end
end
|