diff options
author | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2010-01-28 23:00:58 +0100 |
---|---|---|
committer | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2010-01-28 23:00:58 +0100 |
commit | 42a960b77b6248be1d38bf84d4ba4475f50b66c5 (patch) | |
tree | 786d2c920b311f4c3f6a8feb04366e629170ef86 /timepollhead.rb | |
parent | 25db977338ca2a1138e32315102c5f7434df17cd (diff) |
show in any case from min to max time
Diffstat (limited to 'timepollhead.rb')
-rw-r--r-- | timepollhead.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/timepollhead.rb b/timepollhead.rb index ba649a0..ab0454e 100644 --- a/timepollhead.rb +++ b/timepollhead.rb @@ -46,9 +46,7 @@ class TimePollHead def concrete_times h = {} @data.each{|ds| h[ds.time_to_s] = true } - h.keys.compact.sort{|a,b| - TimeString.new(Date.today,a) <=> TimeString.new(Date.today,b) - } + h.keys end def date_included?(date) ret = false @@ -258,9 +256,15 @@ END "notchosen" => _("notchosen"), "disabled" => _("past") } - times = [] - (9..20).each{|i| times << "#{i.to_s.rjust(2,"0")}:00"} - times << concrete_times + + times = concrete_times + realtimes = times.collect{|t| Time.parse(t) if t =~ /\d\d:\d\d/}.compact + [9,16].each{|i| realtimes << Time.parse("#{i.to_s.rjust(2,"0")}:00")} + + first = realtimes.min.strftime("%H").to_i + last = realtimes.max.strftime("%H").to_i + + (first..last).each{|i| times << "#{i.to_s.rjust(2,"0")}:00" } times.flatten.compact.uniq.sort.each{|time| ret +="<tr>\n<td>#{time}</td>" days.each{|day| |