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
|
# File 'lib/reporter/support/time_range.rb', line 10
def human_name
return inspect unless time_range?
b = test_begin_ends(self.begin)
e = test_begin_ends(self.end)
if self.begin.year == self.end.year
if b[:by] and e[:ey]
return self.begin.strftime("%Y")
elsif b[:bq] and e[:eq]
bq = get_quarter(self.begin)
eq = get_quarter(self.end)
if bq == eq
return I18n.t("time_range.quarter", :year => self.begin.year, :quarter => bq, :default => "q%{quarter} %{year}")
else
return I18n.t("time_range.multi_quarter", :year => self.begin.year,
:begin_quarter => bq, :end_quarter => eq, :default => "q%{begin_quarter} .. q%{end_quarter} %{year}")
end
elsif b[:bm] and e[:em]
if self.begin.month == self.end.month
return self.begin.strftime("%b '%y")
else
return "#{self.begin.strftime("%b")} .. #{self.end.strftime("%b '%y")}"
end
end
else if b[:by] and e[:ey]
return "#{self.begin.strftime("'%y")} .. #{self.end.strftime("'%y")}"
else
return inspect
end
end
end
|