3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'app/helpers/application_helper.rb', line 3
def sexifytime(t, username=nil)
day = case t.day % 10
when 0
"#{t.day}th"
when 1
"#{t.day}st"
when 2
"#{t.day}nd"
when 3
"#{t.day}rd"
else
"#{t.day}th"
end
day = "#{t.day}th" if [12, 13, 14].include? t.day
str = ''
str << link_to(day, :controller => 'post', :action => 'range', :user => username, :year => t.strftime('%Y'), :month => t.strftime('%m'), :day => t.strftime('%d'))
str << ' ' << link_to(t.strftime('%B'), :controller => 'post', :action => 'range', :user => username, :year => t.strftime('%Y'), :month => t.strftime('%m'), :day => nil)
str << ' ' << link_to(t.strftime('%Y'), :controller => 'post', :action => 'range', :user => username, :year => t.strftime('%Y'), :month => nil, :day => nil)
str << ', '
str << case t.hour
when 0..2
'the wee hours'
when 3..6
'terribly early in the morning'
when 7..9
'early morning'
when 10
'mid-morning'
when 11
'late morning'
when 12..13
'lunch time'
when 14
'early afternoon'
when 15..16
'mid-afternoon'
when 17
'late afternoon'
when 18..19
'early evening'
when 20..21
'evening time'
when 22
'late evening'
when 23
'late at night'
end
end
|